diff options
author | rgrimes <rgrimes@FreeBSD.org> | 1994-05-27 12:33:43 +0000 |
---|---|---|
committer | rgrimes <rgrimes@FreeBSD.org> | 1994-05-27 12:33:43 +0000 |
commit | f9ab90d9d6d02989a075d0f0074496d5b1045e4b (patch) | |
tree | add7e996bac5289cdc55e6935750c352505560a9 /usr.bin/tn3270/distribution | |
parent | be22b15ae2ff8d7fe06b6e14fddf0c5b444a95da (diff) | |
download | FreeBSD-src-f9ab90d9d6d02989a075d0f0074496d5b1045e4b.zip FreeBSD-src-f9ab90d9d6d02989a075d0f0074496d5b1045e4b.tar.gz |
BSD 4.4 Lite Usr.bin Sources
Diffstat (limited to 'usr.bin/tn3270/distribution')
23 files changed, 3514 insertions, 0 deletions
diff --git a/usr.bin/tn3270/distribution/README b/usr.bin/tn3270/distribution/README new file mode 100644 index 0000000..29afc73 --- /dev/null +++ b/usr.bin/tn3270/distribution/README @@ -0,0 +1,99 @@ +Welcome to the new tn3270 - version 4.1.1. + +This version consists entirely of bug fixes to the August 1987 beta release +of tn3270. This version will now deal with CICS and VM/XA on the IBM +side, and with SunOS 4.0 on Sun 3's and Sun 4's. + +This version has been tested on various versions of BSD Unix, including +4.2 and 4.3 (but there are never vanilla versions) and the post-4.3 systems +running at Berkeley. It has been tested on CCI's, Vaxen, Sun 3's and Sun 4's. +However, it doesn't necessarily work on all systems (nor has the testing +been as intensive as one might like). + +This version should build on any Berkeley-derived system. + +There are two alternate make files: ./makefile_4.2 and telnet/Makefile_ultrix. + +**** Try ./makefile_4.2 if you get compile-time errors, or get + "multiply defined" messages for "_putchar" from the loader. + +**** Try telnet/Makefile_ultrix if your make(1) utility doesn't + support VPATH. Also try this makefile if your ld(1) doesn't + support the -r flag correctly. + +The bad news is that I've had to drop MS-DOS support. The good news here is +that there are various versions available for MS-DOS (from FTP Software in +Cambridge, Mass.; from IBM; from Excelan; and probably from others). The +hooks are still there, as well as some code to update the screen. However, +I just haven't had the time to produce a fully integrated version that would +"just make". I suspect that a future release may have MS-DOS support back +in it. + +There is no Mac support. Contact Peter DiCamillo at Brown University if +you need a Mac tn3270. + +The main code change in this version is to what used to be called "telnet.c". +This is now replaced with a version of telnet (substantially what appeared +in the "4.3tahoe" release from CSRG) which is broken into separate files. + +Here is an overview of the directory structure: + + api/ General library of function needed by API + (and, to some extent, by the rest of tn3270). + + arpa/ Location of "telnet.h" (for non-4.3 systems). + + ascii/ Routines necessary to handle the case of running + from an ASCII-oriented system (ie: unix). + + ctlr/ The main part of the emulator. Handles 3270 scan + codes, 3270 data stream, 3270 display codes, + and EBCDIC. Also, the internal API function + lives here. + + general/ Some general subroutines and data structures of + interest to the emulator only. + + sys_curses/ System-dependent code for a curses-based environment. + + sys_dos/ System-dependent code for an MS-DOS-base environment. + Remember that this is included for your developmental + needs (ie: it doesn't work). + + telnet/ Where the telnet portion of tn3720 is built. + + tools/ Various tools. Most of these are used during the + build process. One (prt3270) is a debugging tool. + One (mkmake.y) is quite horrible, and attempts to + transform Unix makefiles into PC makefiles. + + utilities/ The source for tnrecv, which receives files + (fairly slowly) from an IBM host. We don't + include the IBM side, because we really aren't + happy with very much of it (except that it does, + sometimes, work). Hopefully, when we get past + the beta stage we will have more robust (and + complete) code to share. + +The fact that system dependancies are isolated should make it easy +to port to other systems. I would like to hear about problems porting +to new areas. + +In the August, 1987 README file, the following appeared: + +> WHAT IS NOT IN THIS VERSION (sigh): + +> 1) We don't have a native X version yet. I am waiting for X version 11 +> (though this is mostly an excuse; I could have done version 10, +> but I haven't had the time). + +> 2) We don't process structured fields. + +> 3) We don't do 3270-style graphics (ala 3193, say). + +> The above three items WILL be in the next version, which should come +> along "any day now" (say 6 months) (but, they WON'T be in the production +> release of this version). + +The next piece of bad news is that none of the above have happened yet, +and I don't know when they might occur. diff --git a/usr.bin/tn3270/distribution/arpa/makefile b/usr.bin/tn3270/distribution/arpa/makefile new file mode 100644 index 0000000..2cf3bc0 --- /dev/null +++ b/usr.bin/tn3270/distribution/arpa/makefile @@ -0,0 +1,67 @@ +# @(#)makefile 8.1 (Berkeley) 6/6/93 + +# msdos versus unix defines +O = .o +#PC_O = .obj + +X = +#PC_X = .exe + +L = +#PC_L = -link + +CC = cc +#PC_CC = cl + +MV = mv +#PC_MV = rename + +RM = rm -f +#PC_RM= erase + +LINT_ARGS = +#PC_LINT_ARGS = -DLINT_ARGS + +DEBUG_FLAGS = -g +#PC_DEBUG_FLAGS = -Zi -Od + +AR = ar +AR1 = cr +AR2 = +AR3 = +#PC_AR = lib +#PC_AR1 = +#PC_AR2 = + +#PC_AR3 = ";" + +RANLIB = ranlib +#PC_RANLIB = echo "Done with " + +PRINT = lpr -p + +ALLC = +ALLH = telnet.h + +ALLPRINT = ${ALLH} ${ALLC} + +ALLSOURCE = ${ALLPRINT} makefile makefile.mak + +clean: + +sccsclean: + -sccs clean + -sccs get makefile + +action: + ${ACTION} + +print: + ${PRINT} ${ALLPRINT} + + +sourcelist: ${ALLSOURCE} + @for i in ${ALLSOURCE}; \ + do (echo ${DIRPATH}$$i); done + +.DEFAULT: + sccs get $< diff --git a/usr.bin/tn3270/distribution/arpa/telnet.h b/usr.bin/tn3270/distribution/arpa/telnet.h new file mode 100644 index 0000000..eeb72c2 --- /dev/null +++ b/usr.bin/tn3270/distribution/arpa/telnet.h @@ -0,0 +1,191 @@ +/*- + * Copyright (c) 1983, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)telnet.h 8.1 (Berkeley) 6/6/93 + */ + +/* + * Definitions for the TELNET protocol. + */ +#define IAC 255 /* interpret as command: */ +#define DONT 254 /* you are not to use option */ +#define DO 253 /* please, you use option */ +#define WONT 252 /* I won't use option */ +#define WILL 251 /* I will use option */ +#define SB 250 /* interpret as subnegotiation */ +#define GA 249 /* you may reverse the line */ +#define EL 248 /* erase the current line */ +#define EC 247 /* erase the current character */ +#define AYT 246 /* are you there */ +#define AO 245 /* abort output--but let prog finish */ +#define IP 244 /* interrupt process--permanently */ +#define BREAK 243 /* break */ +#define DM 242 /* data mark--for connect. cleaning */ +#define NOP 241 /* nop */ +#define SE 240 /* end sub negotiation */ +#define EOR 239 /* end of record (transparent mode) */ +#define ABORT 238 /* Abort process */ +#define SUSP 237 /* Suspend process */ +#define xEOF 236 /* End of file: EOF is already used... */ + +#define SYNCH 242 /* for telfunc calls */ + +#ifdef TELCMDS +char *telcmds[] = { + "EOF", "SUSP", "ABORT", "EOR", + "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC", + "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", +}; +#define TELCMD_FIRST xEOF +#define TELCMD_LAST IAC +#define TELCMD_OK(x) ((x) <= TELCMD_LAST && (x) >= TELCMD_FIRST) +#define TELCMD(x) telcmds[(x)-TELCMD_FIRST] +#endif + +/* telnet options */ +#define TELOPT_BINARY 0 /* 8-bit data path */ +#define TELOPT_ECHO 1 /* echo */ +#define TELOPT_RCP 2 /* prepare to reconnect */ +#define TELOPT_SGA 3 /* suppress go ahead */ +#define TELOPT_NAMS 4 /* approximate message size */ +#define TELOPT_STATUS 5 /* give status */ +#define TELOPT_TM 6 /* timing mark */ +#define TELOPT_RCTE 7 /* remote controlled transmission and echo */ +#define TELOPT_NAOL 8 /* negotiate about output line width */ +#define TELOPT_NAOP 9 /* negotiate about output page size */ +#define TELOPT_NAOCRD 10 /* negotiate about CR disposition */ +#define TELOPT_NAOHTS 11 /* negotiate about horizontal tabstops */ +#define TELOPT_NAOHTD 12 /* negotiate about horizontal tab disposition */ +#define TELOPT_NAOFFD 13 /* negotiate about formfeed disposition */ +#define TELOPT_NAOVTS 14 /* negotiate about vertical tab stops */ +#define TELOPT_NAOVTD 15 /* negotiate about vertical tab disposition */ +#define TELOPT_NAOLFD 16 /* negotiate about output LF disposition */ +#define TELOPT_XASCII 17 /* extended ascic character set */ +#define TELOPT_LOGOUT 18 /* force logout */ +#define TELOPT_BM 19 /* byte macro */ +#define TELOPT_DET 20 /* data entry terminal */ +#define TELOPT_SUPDUP 21 /* supdup protocol */ +#define TELOPT_SUPDUPOUTPUT 22 /* supdup output */ +#define TELOPT_SNDLOC 23 /* send location */ +#define TELOPT_TTYPE 24 /* terminal type */ +#define TELOPT_EOR 25 /* end or record */ +#define TELOPT_TUID 26 /* TACACS user identification */ +#define TELOPT_OUTMRK 27 /* output marking */ +#define TELOPT_TTYLOC 28 /* terminal location number */ +#define TELOPT_3270REGIME 29 /* 3270 regime */ +#define TELOPT_X3PAD 30 /* X.3 PAD */ +#define TELOPT_NAWS 31 /* window size */ +#define TELOPT_TSPEED 32 /* terminal speed */ +#define TELOPT_LFLOW 33 /* remote flow control */ +#define TELOPT_LINEMODE 34 /* Linemode option */ +#define TELOPT_EXOPL 255 /* extended-options-list */ + +#define NTELOPTS (1+TELOPT_LINEMODE) +#ifdef TELOPTS +char *telopts[NTELOPTS] = { + "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME", + "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP", + "NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS", + "NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO", + "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT", + "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD", + "TACACS UID", "OUTPUT MARKING", "TTYLOC", + "3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW", + "LINEMODE", +}; +#define TELOPT_FIRST TELOPT_BINARY +#define TELOPT_LAST TELOPT_LINEMODE +#define TELOPT_OK(x) ((x) <= TELOPT_LAST && (x) >= TELOPT_FIRST) +#define TELOPT(x) telopts[(x)-TELOPT_FIRST] +#endif + +/* sub-option qualifiers */ +#define TELQUAL_IS 0 /* option is... */ +#define TELQUAL_SEND 1 /* send option */ + +/* + * LINEMODE suboptions + */ + +#define LM_MODE 1 +#define LM_FORWARDMASK 2 +#define LM_SLC 3 + +#define MODE_EDIT 0x01 +#define MODE_TRAPSIG 0x02 +#define MODE_ACK 0x04 + +#define MODE_MASK (MODE_EDIT|MODE_TRAPSIG|MODE_ACK) + +/* Not part of protocol, but needed to simplify things... */ +#define MODE_FLOW 0x40 +#define MODE_ECHO 0x80 +#define MODE_FORCE 0x20 + +#define SLC_SYNCH 1 +#define SLC_BRK 2 +#define SLC_IP 3 +#define SLC_AO 4 +#define SLC_AYT 5 +#define SLC_EOR 6 +#define SLC_ABORT 7 +#define SLC_EOF 8 +#define SLC_SUSP 9 +#define SLC_EC 10 +#define SLC_EL 11 +#define SLC_EW 12 +#define SLC_RP 13 +#define SLC_LNEXT 14 +#define SLC_XON 15 +#define SLC_XOFF 16 +#define SLC_FORW1 17 +#define SLC_FORW2 18 + +#define NSLC 18 + +#define SLC_NAMES "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \ + "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \ + "LNEXT", "XON", "XOFF", "FORW1", "FORW2" + +#define SLC_NOSUPPORT 0 +#define SLC_CANTCHANGE 1 +#define SLC_VARIABLE 2 +#define SLC_DEFAULT 3 +#define SLC_LEVELBITS 0x03 + +#define SLC_FUNC 0 +#define SLC_FLAGS 1 +#define SLC_VALUE 2 + +#define SLC_ACK 0x80 +#define SLC_FLUSHIN 0x40 +#define SLC_FLUSHOUT 0x20 diff --git a/usr.bin/tn3270/distribution/makefile_4.2 b/usr.bin/tn3270/distribution/makefile_4.2 new file mode 100644 index 0000000..b8e5eb8e --- /dev/null +++ b/usr.bin/tn3270/distribution/makefile_4.2 @@ -0,0 +1,268 @@ +# @(#)makefile 3.5 (Berkeley) 5/15/88 + +# This makefile will make tn3270 on Vax 4.2 systems. Notice, however, +# that on an ultrix system you will need to use the Makefile_ultrix in +# telnet/ rather than the Makefile already in that directory. + +# Makefile for tn3270 and friends... +# +# This is the makefile for tn3270. Note that we use the 4.3+ telnet +# (compiled with special options; see below) to provide the telnet +# support we need. +# +# The following are the defines that may be passed (via the cc +# -D option) to the compiler. +# +# TN3270 - This is to be linked with tn3270. Necessary +# for creating tn3270. Only for compiling +# telnet. +# +# NOT43 - Allows the program to compile and run on +# a 4.2BSD system. +# +# PUTCHAR - Within tn3270, on a NOT43 system, +# allows the use of the 4.3 curses +# (greater speed updating the screen). +# You need the 4.3 curses for this to work. +# +# FD_SETSIZE - On whichever system, if this isn't defined, +# we patch over the FD_SET, etc., macros with +# some homebrewed ones. +# +# SO_OOBINLINE - This is a socket option which we would like +# to set to allow TCP urgent data to come +# to us "inline". This is NECESSARY for +# CORRECT operation, and desireable for +# simpler operation. +# +# LNOFLSH - Detects the presence of the LNOFLSH bit +# in the tty structure. +# +# +# Here are some which are used throughout the system: +# +# unix - Compiles in unix specific stuff. +# +# msdos - Compiles in msdos specific stuff. +# + +# msdos versus unix defines +O = .o +#PC_O = .obj + +X = +#PC_X = .exe + +L = +#PC_L = -link + +CC = cc +#PC_CC = cl + +MV = mv +#PC_MV = rename + +RM = rm -f +#PC_RM= erase + +LINT_ARGS = +#PC_LINT_ARGS = -DLINT_ARGS + +DEBUG_FLAGS = -g +#PC_DEBUG_FLAGS = -Zi -Od + +AR = ar +AR1 = cr +AR2 = +AR3 = +#PC_AR = lib +#PC_AR1 = +#PC_AR2 = + +#PC_AR3 = ";" + +RANLIB = ranlib +#PC_RANLIB = echo "Done with " + + +PRINT = print +ACTION = @sccs tell + +DEFINES = -DNOT43 ${LINT_ARGS} + +INCLUDES = -I. -I.. + +OPTIMIZE = -O +OPTIMIZE = ${DEBUG_FLAGS} + +CFLAGS = $(OPTIMIZE) $(INCLUDES) $(DEFINES) + +# Lint flags +LINTFLAGS = -hbxaz +# How to install the bloody thing... + +DESTDIR= + +BINDIR = $(DESTDIR)/usr/ucb + +# Names for the terminal libraries... +LIBCURSES = -lcurses +LIBTERM = -ltermlib + +#PC_LIBCURSES = +#PC_LIBTERM = + +# The source files... +ALLH = telnet.ext + +MSMAIN = ascii/mset.c + +ALLC = + +ALLO = mset$O + +ALLHC= ${ALLH} ${ALLC} +ALLPRINT = ${ALLHC} + +ALLSOURCE = ${ALLPRINT} makefile makefile.mak makefile_4.2 README + +SYS = sys_curses +#PC_SYS = sys_dos + +# The places where the various components live... + +SUBDIR = api ascii ctlr general ${SYS} telnet + +# The following are directories we don't do regular make's in, but +# we do make everywhere, print, and sourcelist in. + +EXTRADIR = arpa sys_dos tools utilities + +# The libraries we use. The order here is important. +# syslib.a and ctlrlib.a should come first, then the rest. +SUBLIB = ${SYS}/syslib.a ctlr/ctlrlib.a \ + ascii/asciilib.a general/generallib.a + +.s.o: + /lib/cpp -E $< | as -o $@ + +.c.obj: + ${CC} ${CFLAGS} -c $< + +all: FRC tn3270$X mset$X + +FRC: + for i in ${SUBDIR}; \ + do (cd $$i; make ${MFLAGS} "CFLAGS=${CFLAGS}"); done + +tn3270$X: telnet/telprog.o ${SUBLIB} api/apilib.a + ${CC} ${CFLAGS} -o tn3270 telnet/telprog.o \ + $L ${SUBLIB} api/apilib.a $(LIBCURSES) $(LIBTERM) + +#PC_tn3270$X: +#PC_ link <@< +#PC_ telnet +#PC_ tn3270 +#PC_ nul +#PC_ ${SUBLIB} api/apilib.a+ +#PC_ \lib\ublib\ubtcp +#PC_ _PC_< + +mset$X: mset$O ascii/map3270$O + ${CC} ${CFLAGS} -o mset mset$O ascii/map3270$O $L api/apilib.a + +mset$O: $(MSMAIN) + $(CC) $(CFLAGS) -c $(MSMAIN) + +install: tn3270$X mset$X + install -m 755 -o bin -g bin -s tn3270 $(BINDIR) + install -m 755 -o bin -g bin -s mset $(BINDIR) + +action: + ${ACTION} + +clist: ${ALLHC} + @for i in ${SUBDIR}; \ + do (cd $$i; make ${MFLAGS} "DIRPATH=${DIRPATH}$$i/" \ + clist); done + +hclist: ${ALLHC} + @for i in ${SUBDIR}; \ + do (cd $$i; make ${MFLAGS} "DIRPATH=${DIRPATH}$$i/" \ + hclist); done + +everywhere: action + for i in ${SUBDIR} ${EXTRADIR}; \ + do (echo "[$$i]"; cd $$i; make ${MFLAGS} action \ + "ACTION=${ACTION}"); done + +clean: + for i in $(ALLO) mset tn3270 errs makefile.bak; \ + do (${RM} $$i); done + for i in ${SUBDIR} ${EXTRADIR}; \ + do (cd $$i; make ${MFLAGS} clean); done + +sccsclean: + -sccs clean + -sccs get makefile + for i in ${SUBDIR} ${EXTRADIR}; \ + do (cd $$i; make ${MFLAGS} sccsclean); done + +print: + ${PRINT} ${ALLPRINT} + for i in ${SUBDIR} ${EXTRADIR}; \ + do (cd $$i; make ${MFLAGS} "PRINT=${PRINT}" print); done + +tags: ${ALLC} ${ALLH} + ctags -t `make ${MFLAGS} hclist` + +sourcelist: ${ALLSOURCE} + @for i in ${ALLSOURCE}; \ + do (echo ${DIRPATH}$$i); done + @for i in ${SUBDIR} ${EXTRADIR}; \ + do (cd $$i; make ${MFLAGS} "DIRPATH=${DIRPATH}$$i/" \ + sourcelist); done + +lint: + lint ${LINTFLAGS} ${INCLUDES} ${DEFINES} -DTN3270 \ + `make clist` -lcurses + +lintmset: + lint ${LINTFLAGS} ${INCLUDES} ${DEFINES} ${MSMAIN} \ + ascii/map3270.c -lcurses + +makefiles.pc: tools/mkmake + for i in . ${SUBDIR} ${EXTRADIR}; \ + do (sed -e "s/lib\.a/.lib/g" -e "s/^#PC_//" < $$i/makefile | \ + ./tools/mkmake | \ + sed -e "sx/x\\\\xg" -e "s/[ ]*_PC_//" > $$i/makefile.mak); \ + done + +tools/mkmake: + (cd tools; make mkmake) + +.DEFAULT: + sccs get $< + +depend: thisdepend + for i in ${SUBDIR}; do (cd $$i; make ${MFLAGS} depend); done + +thisdepend: + echo > eddep.c + grep '^#include' ${ALLC} eddep.c | grep -v '<' | \ + sed -e 's/:[^"]*"\([^"]*\)".*/: \1/' \ + -e 's/\.c/$$O/' | \ + awk ' { if ($$1 != prev) { print rec; rec = $$0; prev = $$1; } \ + else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \ + else rec = rec " " $$2 } } \ + END { print rec } ' > makedep + echo '$$r makedep' >>eddep + echo '/^# DO NOT DELETE THIS LINE/+1,$$d' >eddep + echo '$$r makedep' >>eddep + echo 'w' >>eddep + -rm -f makefile.bak + cp makefile makefile.bak + ed - makefile < eddep + rm eddep makedep eddep.c + +# DO NOT DELETE THIS LINE + diff --git a/usr.bin/tn3270/distribution/sys_dos/makefile b/usr.bin/tn3270/distribution/sys_dos/makefile new file mode 100644 index 0000000..4188f9f --- /dev/null +++ b/usr.bin/tn3270/distribution/sys_dos/makefile @@ -0,0 +1,127 @@ +# @(#)makefile 8.1 (Berkeley) 6/6/93 + +# msdos versus unix defines +O = .o +#PC_O = .obj + +X = +#PC_X = .exe + +L = +#PC_L = -link + +CC = cc +#PC_CC = cl + +MV = mv +#PC_MV = rename + +RM = rm -f +#PC_RM= erase + +LINT_ARGS = +#PC_LINT_ARGS = -DLINT_ARGS + +DEBUG_FLAGS = -g +#PC_DEBUG_FLAGS = -Zi -Od + +AR = ar +AR1 = cr +AR2 = +AR3 = +#PC_AR = lib +#PC_AR1 = +#PC_AR2 = + +#PC_AR3 = ";" + +RANLIB = ranlib +#PC_RANLIB = echo "Done with " + +PRINT = print + +DEFINES = ${LINT_ARGS} + +INCLUDES = -I. + +OPTIMIZE = -O +OPTIMIZE = ${DEBUG_FLAGS} + +CFLAGS = $(OPTIMIZE) $(INCLUDES) $(DEFINES) + +# Lint flags +LINTFLAGS = -hbxaz + +ALLH = spint.h video.h + +ALLC = spintc.c system.c termout.c + +ALLASM = spintasm.asm support.asm + +ALLO = spintasm$O spintc$O support$O system$O termout$O + +ALLPRINT = ${ALLH} ${ALLASM} ${ALLC} + +ALLSOURCE = ${ALLPRINT} makefile makefile.mak + +.c.obj: + ${CC} ${CFLAGS} -c $< + +syslib.a: $(ALLO) + ${RM} $@ + for i in ${ALLO}; do (${AR} ${AR1} $@ ${AR2} $$i${AR3}); done + ${RANLIB} $@ + +clean: + for i in $(ALLO) errs makefile.bak syslib.a; \ + do (${RM} $$i); done + +sccsclean: + -sccs clean + -sccs get makefile + +sourcelist: ${ALLSOURCE} + @for i in ${ALLSOURCE}; \ + do (echo ${DIRPATH}$$i); done + +print: + ${PRINT} ${ALLPRINT} + +tags: ${ALLC} ${ALLH} + ctags -t ${ALLC} ${ALLH} + +action: + ${ACTION} + +lint: + lint ${LINTFLAGS} ${INCLUDES} ${DEFINES} -DTN3270 \ + ${TNMAIN} ${MOSTC} -lcurses + lint ${LINTFLAGS} ${INCLUDES} ${DEFINES} ${MSMAIN} map3270.c -lcurses + +.DEFAULT: + sccs get $< + +depend: + grep '^#include' ${ALLC} ${ALLH} | grep -v '<' | \ + sed -e 's/:[^"]*"\([^"]*\)".*/: \1/' \ + -e 's/\.c/$$O/' | \ + awk ' { if ($$1 != prev) { print rec; rec = $$0; prev = $$1; } \ + else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \ + else rec = rec " " $$2 } } \ + END { print rec } ' > makedep + echo '$$r makedep' >>eddep + echo '/^# DO NOT DELETE THIS LINE/+1,$$d' >eddep + echo '$$r makedep' >>eddep + echo 'w' >>eddep + -rm -f makefile.bak + cp makefile makefile.bak + ed - makefile < eddep + rm eddep makedep + +# DO NOT DELETE THIS LINE + +spintc$O: ../general/general.h spint.h +system$O: ../general/general.h ../ctlr/api.h spint.h ../general/globals.h +termout$O: ../general/general.h ../api/disp_asc.h +termout$O: ../ctlr/hostctlr.h +termout$O: ../ctlr/oia.h +termout$O: ../ctlr/screen.h ../general/globals.h video.h diff --git a/usr.bin/tn3270/distribution/sys_dos/spint.h b/usr.bin/tn3270/distribution/sys_dos/spint.h new file mode 100644 index 0000000..023ee52 --- /dev/null +++ b/usr.bin/tn3270/distribution/sys_dos/spint.h @@ -0,0 +1,49 @@ +/*- + * Copyright (c) 1988, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)spint.h 8.1 (Berkeley) 6/6/93 + */ + +/* + * The 'spint' (spawn and interrupt) routines use this structure. + * + * Note that spint_asm.asm contains an Assembly language version of + * the following, so keep changes in synch! + */ + +typedef struct { + union REGS regs; + struct SREGS sregs; + int int_no; /* Which interrupt to wait on */ + int done; /* Are we done, or just took an interrupt? */ + int rc; /* return code */ +} Spint; diff --git a/usr.bin/tn3270/distribution/sys_dos/spintasm.asm b/usr.bin/tn3270/distribution/sys_dos/spintasm.asm new file mode 100644 index 0000000..72efdec --- /dev/null +++ b/usr.bin/tn3270/distribution/sys_dos/spintasm.asm @@ -0,0 +1,252 @@ +; Copyright (c) 1988, 1993 +; The Regents of the University of California. All rights reserved. +; +; Redistribution and use in source and binary forms, with or without +; modification, are permitted provided that the following conditions +; are met: +; 1. Redistributions of source code must retain the above copyright +; notice, this list of conditions and the following disclaimer. +; 2. Redistributions in binary form must reproduce the above copyright +; notice, this list of conditions and the following disclaimer in the +; documentation and/or other materials provided with the distribution. +; 3. All advertising materials mentioning features or use of this software +; must display the following acknowledgement: +; This product includes software developed by the University of +; California, Berkeley and its contributors. +; 4. Neither the name of the University nor the names of its contributors +; may be used to endorse or promote products derived from this software +; without specific prior written permission. +; +; THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +; ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +; OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +; LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +; OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +; SUCH DAMAGE. +; +; @(#)spintasm.asm 8.1 (Berkeley) 6/6/93 +; + +; The code in this file complete the spint calls + +spint struc +; union REGS +spint_ax dw 1 +spint_bx dw 1 +spint_cx dw 1 +spint_dx dw 1 +spint_si dw 1 +spint_di dw 1 +spint_cflag dw 1 +; struct SREGS +spint_es dw 1 +spint_cs dw 1 +spint_ss dw 1 +spint_ds dw 1 +; int intno +spint_intno dw 1 +; int done +spint_done dw 1 +; int rc +spint_rc dw 1 +; +spint ends + + +ENTER MACRO + ; Begin enter + push bp + mov bp,sp + + push ax + push bx + push cx + push dx + push bp + push di + push si + push ds + push es + pushf + + mov cs:start_sp, sp + mov cs:start_ss, ss + ; End enter + ENDM + +LEAVE MACRO + ; Begin leave + cli + mov sp, cs:start_sp + mov ss, cs:start_ss + sti + + popf + pop es + pop ds + pop si + pop di + pop bp + pop dx + pop cx + pop bx + pop ax + + mov sp,bp + pop bp + ret + ; End leave + ENDM + +GETREGS MACRO wherefrom + mov si, wherefrom + mov spint_segment, ds + mov spint_offset, si + + mov ax, spint_ax[si] + mov bx, spint_bx[si] + mov cx, spint_cx[si] + mov dx, spint_dx[si] + ; XXX mov si, spint_si[si] + mov di, spint_di[si] + mov es, spint_es[si] + ; Now, need to do DS, SI + push spint_ds[si] + mov si, spint_si[si] + pop ds + ENDM + + +SETREGS MACRO + mov cs:old_si, si + mov cs:old_ds, ds + + mov ds, cs:spint_segment + mov si, cs:spint_offset + + mov spint_ax[si], ax + mov spint_bx[si], bx + mov spint_cx[si], cx + mov spint_dx[si], dx + + mov spint_si[si], si + mov spint_di[si], di + + mov spint_cs[si], cs + mov spint_ds[si], ds + mov spint_es[si], es + mov spint_ss[si], ss + ; now, need to do SI, DS + mov ax, old_si + mov spint_si[si], ax + mov ax, old_ds + mov spint_ds[si], ax + ENDM + + +_TEXT segment byte public 'CODE' +_TEXT ends + +_DATA segment word public 'DATA' +_DATA ends + +CONST segment word public 'CONST' +CONST ends + +_BSS segment word public 'BSS' +_BSS ends + +DGROUP group CONST, _BSS, _DATA + + assume cs:_TEXT, ds:DGROUP, ss:DGROUP, es:DGROUP + +_TEXT segment + +start_sp dw 1 dup (?) ; For use in our 'longjmp' +start_ss dw 1 dup (?) ; For use in our 'longjmp' + +spint_segment dw 1 dup (?) ; Segment of spawn control block +spint_offset dw 1 dup (?) ; Offset of spawn control block + +old_si dw 1 dup (?) ; SI of interrupt issuer (temporary) +old_ds dw 1 dup (?) ; DS of interrupt issuer (temporary) + +issuer_ss dw 1 dup (?) ; ss of person who called us (permanent) +issuer_sp dw 1 dup (?) ; sp of person who called us (permanent) + +int21_stack db 100 dup (?) ; Stack for int21. + +; +; _spint_int gets control on an interrupt. It switches the stack +; and does a 'return' from _spint_start. +; + public __spint_int + +__spint_int proc near + mov cs:issuer_sp, sp + mov cs:issuer_ss, ss + sti + + SETREGS + + LEAVE +__spint_int endp + +; +; _spint_start issues the dos interrupt after setting up the passed +; registers. When control returns to it, it sets spint->done to non-zero. +; + public __spint_start + +__spint_start proc near + ENTER + + GETREGS 4[bp] + + ; Now, switch to a different (short) stack. This is so + ; that our games won't mess up the stack int 21 (hardware and, + ; possibly, software) stores things on. + + cli + mov cs:int21_stack, cs + mov ss, cs:int21_stack + mov sp, offset int21_stack + add sp, (length int21_stack) - 4 + sti + + int 21H ; Issue DOS interrupt + + SETREGS + + mov ds, cs:spint_segment + mov si, cs:spint_offset + mov spint_done[si], 1 ; We are done + + LEAVE +__spint_start endp + +; +; After _spint_int has faked a return from start_spawn, we come here to +; return to the interrupt issuer. +; + public __spint_continue + +__spint_continue proc near + ENTER + + GETREGS 4[bp] + + mov sp, cs:issuer_sp ; Restore SP + mov ss, cs:issuer_ss ; Restore SS + + iret +__spint_continue endp + +_TEXT ends + + end diff --git a/usr.bin/tn3270/distribution/sys_dos/spintc.c b/usr.bin/tn3270/distribution/sys_dos/spintc.c new file mode 100644 index 0000000..aa16405 --- /dev/null +++ b/usr.bin/tn3270/distribution/sys_dos/spintc.c @@ -0,0 +1,186 @@ +/*- + * Copyright (c) 1988, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)spintc.c 8.1 (Berkeley) 6/6/93"; +#endif /* not lint */ + +#include <stdio.h> +#include <dos.h> +#include <stdlib.h> + +#include "../general/general.h" +#include "spint.h" + +#define PSP_ENVIRONMENT 0x2c +#define PSP_FCB1 0x5c +#define PSP_FCB2 0x6c + +typedef struct { + int + environment, /* Segment address of environment */ + cmd_ptr_offset, /* Offset of command to execute */ + cmd_ptr_segment, /* Segment where command lives */ + fcb1_ptr_offset, /* Offset of FCB 1 */ + fcb1_ptr_segment, /* Segment of FCB 1 */ + fcb2_ptr_offset, /* Offset of FCB 2 */ + fcb2_ptr_segment; /* Segment of FCB 2 */ +} ExecList; + + +static int int_offset, int_segment; + + +void +spint_finish(spint) +Spint *spint; +{ + union REGS regs; + struct SREGS sregs; + + if (spint->done == 0) { + return; /* Not done yet */ + } + + /* + * Restore old interrupt handler. + */ + + regs.h.ah = 0x25; + regs.h.al = spint->int_no; + regs.x.dx = int_offset; + sregs.ds = int_segment; + intdosx(®s, ®s, &sregs); + + if (spint->regs.x.cflag) { + fprintf(stderr, "0x%x return code from EXEC.\n", spint->regs.x.ax); + spint->done = 1; + spint->rc = 99; + return; + } + + regs.h.ah = 0x4d; /* Get return code */ + + intdos(®s, ®s); + + spint->rc = regs.x.ax; +} + +void +spint_continue(spint) +Spint *spint; +{ + _spint_continue(spint); /* Return to caller */ + spint_finish(spint); +} + + +void +spint_start(command, spint) +char *command; +Spint *spint; +{ + ExecList mylist; + char *comspec; + void _spint_int(); + union REGS regs; + struct SREGS sregs; + + /* + * Get comspec. + */ + comspec = getenv("COMSPEC"); + if (comspec == 0) { /* Can't find where command.com is */ + fprintf(stderr, "Unable to find COMSPEC in the environment."); + spint->done = 1; + spint->rc = 99; /* XXX */ + return; + } + + /* + * Now, hook up our interrupt routine. + */ + + regs.h.ah = 0x35; + regs.h.al = spint->int_no; + intdosx(®s, ®s, &sregs); + + /* Save old routine */ + int_offset = regs.x.bx; + int_segment = sregs.es; + + regs.h.ah = 0x25; + regs.h.al = spint->int_no; + regs.x.dx = (int) _spint_int; + segread(&sregs); + sregs.ds = sregs.cs; + intdosx(®s, ®s, &sregs); + + /* + * Read in segment registers. + */ + + segread(&spint->sregs); + + /* + * Set up registers for the EXEC call. + */ + + spint->regs.h.ah = 0x4b; + spint->regs.h.al = 0; + spint->regs.x.dx = (int) comspec; + spint->sregs.es = spint->sregs.ds; /* Superfluous, probably */ + spint->regs.x.bx = (int) &mylist; + + /* + * Set up EXEC parameter list. + */ + + ClearElement(mylist); + mylist.cmd_ptr_offset = (int) command; + mylist.cmd_ptr_segment = spint->sregs.ds; + mylist.fcb1_ptr_offset = PSP_FCB1; + mylist.fcb1_ptr_segment = _psp; + mylist.fcb2_ptr_offset = PSP_FCB2; + mylist.fcb2_ptr_segment = _psp; + mylist.environment = *((int far *)(((long)_psp<<16)|PSP_ENVIRONMENT)); + + /* + * Call to assembly language routine to actually set up for + * the spint. + */ + + _spint_start(spint); + + spint_finish(spint); +} diff --git a/usr.bin/tn3270/distribution/sys_dos/support.asm b/usr.bin/tn3270/distribution/sys_dos/support.asm new file mode 100644 index 0000000..a51c41d --- /dev/null +++ b/usr.bin/tn3270/distribution/sys_dos/support.asm @@ -0,0 +1,60 @@ +; Copyright (c) 1988, 1993 +; The Regents of the University of California. All rights reserved. +; +; Redistribution and use in source and binary forms, with or without +; modification, are permitted provided that the following conditions +; are met: +; 1. Redistributions of source code must retain the above copyright +; notice, this list of conditions and the following disclaimer. +; 2. Redistributions in binary form must reproduce the above copyright +; notice, this list of conditions and the following disclaimer in the +; documentation and/or other materials provided with the distribution. +; 3. All advertising materials mentioning features or use of this software +; must display the following acknowledgement: +; This product includes software developed by the University of +; California, Berkeley and its contributors. +; 4. Neither the name of the University nor the names of its contributors +; may be used to endorse or promote products derived from this software +; without specific prior written permission. +; +; THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +; ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +; OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +; LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +; OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +; SUCH DAMAGE. +; +; @(#)support.asm 8.1 (Berkeley) 6/6/93 +; + +_TEXT segment byte public 'CODE' +_TEXT ends + +_DATA segment word public 'DATA' +_DATA ends + +CONST segment word public 'CONST' +CONST ends + +_BSS segment word public 'BSS' +_BSS ends + +DGROUP group CONST, _BSS, _DATA + + assume cs:_TEXT, ds:DGROUP, ss:DGROUP, es:DGROUP + +_TEXT segment + public _iret_subr + +_iret_subr proc far + iret +_iret_subr endp + +_TEXT ends + + end diff --git a/usr.bin/tn3270/distribution/sys_dos/system.c b/usr.bin/tn3270/distribution/sys_dos/system.c new file mode 100644 index 0000000..864926b --- /dev/null +++ b/usr.bin/tn3270/distribution/sys_dos/system.c @@ -0,0 +1,140 @@ +/*- + * Copyright (c) 1988, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)system.c 8.1 (Berkeley) 6/6/93"; +#endif /* not lint */ + +#include <stdio.h> + +#include "../general/general.h" +#include "../ctlr/api.h" +#include "spint.h" + +#include "../general/globals.h" + + +static Spint spinted; +static char command[256]; +static int need_to_start = 0; + +/* + * shell_continue() actually runs the command, and looks for API + * requests coming back in. + * + * We are called from the main loop in telnet.c. + */ + +int +shell_continue() +{ + /* + * spint_start() returns when either the command has finished, or when + * the required interrupt comes in. In the latter case, the appropriate + * thing to do is to process the interrupt, and then return to + * the interrupt issuer by calling spint_continue(). + */ + if (need_to_start) { + need_to_start = 0; + spint_start(command, &spinted); + } + + if (spinted.done == 0) { + /* Process request */ + handle_api(&spinted.regs, &spinted.sregs); + spint_continue(&spinted); + } else { + char inputbuffer[100]; + + if (spinted.rc != 0) { + fprintf(stderr, "Process generated a return code of 0x%x.\n", + spinted.rc); + } + printf("[Hit return to continue]"); + fflush(stdout); + (void) gets(inputbuffer); + shell_active = 0; + setconnmode(); + ConnectScreen(); + } + return shell_active; +} + + +/* + * Called from telnet.c to fork a lower command.com. We + * use the spint... routines so that we can pick up + * interrupts generated by application programs. + */ + + +int +shell(argc,argv) +int argc; +char *argv[]; +{ + + ClearElement(spinted); + spinted.int_no = API_INTERRUPT_NUMBER; + if (argc == 1) { + command[0] = 0; + } else { + char *cmdptr; + int length; + + argc--; + argv++; + strcpy(command, " /c"); + cmdptr = command+strlen(command); + while (argc) { + if ((cmdptr+strlen(*argv)) >= (command+sizeof command)) { + fprintf(stderr, "Argument list too long at argument *%s*.\n", + *argv); + return 0; + } + *cmdptr++ = ' '; /* Blank separators */ + strcpy(cmdptr, *argv); + cmdptr += strlen(cmdptr); + argc--; + argv++; + } + length = strlen(command)-1; + if (length < 0) { + length = 0; + } + command[0] = length; + } + need_to_start = 1; + shell_active = 1; + return 1; /* Go back to main loop */ +} diff --git a/usr.bin/tn3270/distribution/sys_dos/termout.c b/usr.bin/tn3270/distribution/sys_dos/termout.c new file mode 100644 index 0000000..0339072 --- /dev/null +++ b/usr.bin/tn3270/distribution/sys_dos/termout.c @@ -0,0 +1,514 @@ +/*- + * Copyright (c) 1988, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)termout.c 8.1 (Berkeley) 6/6/93"; +#endif /* not lint */ + +#include <stdio.h> +#include <dos.h> +#include "../general/general.h" + +#include "../telnet.ext" + +#include "../api/disp_asc.h" +#include "../ascii/map3270.ext" + +#include "../ctlr/hostctlr.h" +#include "../ctlr/externs.h" +#include "../ctlr/declare.h" +#include "../ctlr/oia.h" +#include "../ctlr/screen.h" + +#include "../general/globals.h" + +#include "video.h" + +extern void EmptyTerminal(); + +#define CorrectTerminalCursor() ((TransparentClock == OutputClock)? \ + terminalCursorAddress:UnLocked? CursorAddress: HighestScreen()) + + +static int terminalCursorAddress; /* where the cursor is on term */ +static int screenInitd; /* the screen has been initialized */ +static int screenStopped; /* the screen has been stopped */ + +static int needToRing; /* need to ring terinal bell */ + +typedef struct { + char + data, /* The data for this position */ + attr; /* The attributes for this position */ +} ScreenBuffer; + +ScreenBuffer Screen[MAXNUMBERLINES*MAXNUMBERCOLUMNS]; +ScreenBuffer saveScreen[sizeof Screen/sizeof Screen[0]]; + +/* OurExitString - designed to keep us from going through infinite recursion */ + +static void +OurExitString(file, string, value) +FILE *file; +char *string; +int value; +{ + static int recursion = 0; + + if (!recursion) { + recursion = 1; + ExitString(file, string, value); + } +} + + +static void +GoAway(from, where) +char *from; /* routine that gave error */ +int where; /* cursor address */ +{ + char foo[100]; + + sprintf(foo, "ERR from %s at %d (%d, %d)\n", + from, where, ScreenLine(where), ScreenLineOffset(where)); + OurExitString(stderr, foo, 1); + /* NOTREACHED */ +} + +/* + * Routines to deal with the screen. These routines are lifted + * from mskermit. + */ + +#define CRT_STATUS 0x3da /* Color card */ +#define DISPLAY_ENABLE 0x08 /* Enable */ +#define scrseg() ((crt_mode == 7)? 0xb000 : 0xb800) +#define scrwait() if (crt_mode != 7) { \ + while ((inp(CRT_STATUS)&DISPLAY_ENABLE) == 0) { \ + ; \ + } \ + } +static int + crt_mode, + crt_cols, + crt_lins, + curpage; + +/* + * Set the cursor position to where it belongs. + */ + +static void +setcursor(row, column, page) +int + row, + column, + page; +{ + union REGS inregs, outregs; + + inregs.h.dh = row; + inregs.h.dl = column; + inregs.h.bh = page; + inregs.h.ah = SetCursorPosition; + + int86(BIOS_VIDEO, &inregs, &outregs); +} +/* + * Read the state of the video system. Put the cursor somewhere + * reasonable. + */ + +static void +scrini() +{ + union REGS inregs, outregs; + + inregs.h.ah = CurrentVideoState; + int86(BIOS_VIDEO, &inregs, &outregs); + + crt_mode = outregs.h.al; + crt_cols = outregs.h.ah; + crt_lins = 25; + curpage = outregs.h.bh; + + inregs.h.ah = ReadCursorPosition; + inregs.h.bh = curpage; + + int86(BIOS_VIDEO, &inregs, &outregs); + + if (outregs.h.dh > crt_lins) { + outregs.h.dh = crt_lins; + } + if (outregs.h.dl > crt_cols) { + outregs.h.dl = crt_cols; + } + inregs.h.dh = outregs.h.dh; + inregs.h.dl = outregs.h.dl; + inregs.h.bh = curpage; + + inregs.h.ah = SetCursorPosition; + int86(BIOS_VIDEO, &inregs, &outregs); +} + + +static void +scrwrite(source, length, offset) +ScreenBuffer *source; +int + length, + offset; +{ + struct SREGS segregs; + + segread(&segregs); /* read the current segment register */ + + scrwait(); + movedata(segregs.ds, source, scrseg(), sizeof *source*offset, + sizeof *source*length); +} + +static void +scrsave(buffer) +ScreenBuffer *buffer; +{ + struct SREGS segregs; + + segread(&segregs); /* read the current segment register */ + + scrwait(); + movedata(scrseg(), 0, segregs.ds, buffer, crt_cols*crt_lins*2); +} + +static void +scrrest(buffer) +ScreenBuffer *buffer; +{ + scrwrite(buffer, crt_cols*crt_lins, 0); +} + +static void +TryToSend() +{ +#define STANDOUT 0x0a /* Highlighted mode */ +#define NORMAL 0x02 /* Normal mode */ +#define NONDISPLAY 0x00 /* Don't display */ + +#define DoAttribute(a) \ + if (screenIsFormatted) { \ + if (IsNonDisplayAttr(a)) { \ + a = NONDISPLAY; /* don't display */ \ + } else if (IsHighlightedAttr(a)) { \ + a = STANDOUT; \ + } else { \ + a = NORMAL; \ + } \ + } else { \ + a = NORMAL; /* do display on unformatted */\ + } + ScreenImage *p, *upper; + ScreenBuffer *sp; + int fieldattr; /* spends most of its time == 0 or 1 */ + int screenIsFormatted = FormattedScreen(); + +/* OK. We want to do this a quickly as possible. So, we assume we + * only need to go from Lowest to Highest. However, if we find a + * field in the middle, we do the whole screen. + * + * In particular, we separate out the two cases from the beginning. + */ + if ((Highest != HighestScreen()) || (Lowest != LowestScreen())) { + sp = &Screen[Lowest]; + p = &Host[Lowest]; + upper = &Host[Highest]; + fieldattr = FieldAttributes(Lowest); + DoAttribute(fieldattr); /* Set standout, non-display status */ + + while (p <= upper) { + if (IsStartFieldPointer(p)) { /* New field? */ + Highest = HighestScreen(); + Lowest = LowestScreen(); + TryToSend(); /* Recurse */ + return; + } else if (fieldattr) { /* Should we display? */ + /* Display translated data */ + sp->data = disp_asc[GetHostPointer(p)]; + } else { + sp->data = ' '; + } + sp->attr = fieldattr; + p++; + sp++; + } + } else { /* Going from Lowest to Highest */ + ScreenImage *End = &Host[ScreenSize]-1; + + sp = Screen; + p = Host; + fieldattr = FieldAttributes(LowestScreen()); + DoAttribute(fieldattr); /* Set standout, non-display status */ + + while (p <= End) { + if (IsStartFieldPointer(p)) { /* New field? */ + fieldattr = FieldAttributesPointer(p); /* Get attributes */ + DoAttribute(fieldattr); /* Set standout, non-display */ + } + if (fieldattr) { /* Should we display? */ + /* Display translated data */ + sp->data = disp_asc[GetHostPointer(p)]; + } else { + sp->data = ' '; + } + sp->attr = fieldattr; + p++; + sp++; + } + } + terminalCursorAddress = CorrectTerminalCursor(); + /* + * We might be here just to update the cursor address. + */ + if (Highest >= Lowest) { + scrwrite(Screen+Lowest, (1+Highest-Lowest), Lowest); + } + setcursor(ScreenLine(terminalCursorAddress), + ScreenLineOffset(terminalCursorAddress), 0); + Lowest = HighestScreen()+1; + Highest = LowestScreen()-1; + if (needToRing) { + DataToTerminal("\7", 1); + needToRing = 0; + } + return; +} + +/* InitTerminal - called to initialize the screen, etc. */ + +void +InitTerminal() +{ + InitMapping(); /* Go do mapping file (MAP3270) first */ + if (!screenInitd) { /* not initialized */ + MaxNumberLines = 24; /* XXX */ + MaxNumberColumns = 80; /* XXX */ + scrini(); + scrsave(saveScreen); /* Save the screen buffer away */ + ClearArray(Screen); + terminalCursorAddress = SetBufferAddress(0,0); + screenInitd = 1; + screenStopped = 0; /* Not stopped */ + } +} + + +/* StopScreen - called when we are going away... */ + +void +StopScreen(doNewLine) +int doNewLine; +{ + if (screenInitd && !screenStopped) { + scrrest(saveScreen); + setcursor(NumberLines-1, 1, 0); + if (doNewLine) { + StringToTerminal("\r\n"); + } + EmptyTerminal(); + screenStopped = 1; + } +} + + +/* RefreshScreen - called to cause the screen to be refreshed */ + +void +RefreshScreen() +{ + Highest = HighestScreen(); + Lowest = LowestScreen(); + TryToSend(); +} + + +/* ConnectScreen - called to reconnect to the screen */ + +void +ConnectScreen() +{ + if (screenInitd) { + RefreshScreen(); + screenStopped = 0; + } +} + +/* LocalClearScreen() - clear the whole ball of wax, cheaply */ + +void +LocalClearScreen() +{ + Clear3270(); + Lowest = LowestScreen(); /* everything in sync... */ + Highest = HighestScreen(); + TryToSend(); +} + +/* + * Implement the bell/error message function. + */ + +int + bellwinup = 0; /* If != 0, length of bell message */ +static int + bell_len = 0; /* Length of error message */ + + +void +BellOff() +{ + ScreenBuffer a[100]; + int i; + + if (bellwinup) { + unsigned char blank = ' '; + + for (i = 0; i < bell_len; i++) { + a[i].attr = NORMAL; + a[i].data = ' '; + } + } + scrwrite(a, bell_len, 24*80); /* XXX */ +} + + +void +RingBell(s) +char *s; +{ + needToRing = 1; + if (s) { + int i; + ScreenBuffer bellstring[100]; + + bell_len = strlen(s); + bellwinup = 1; + if (bell_len > sizeof bellstring-1) { + OurExitString(stderr, "Bell string too long.", 1); + } + for (i = 0; i < bell_len; i++) { + bellstring[i].attr = STANDOUT; + bellstring[i].data = s[i]; + } + scrwrite(bellstring, bell_len, 24*80); /* XXX */ + } +} + +/* + * Update the OIA area. + */ + +void +ScreenOIA(oia) +OIA *oia; +{ +} + + +/* returns a 1 if no more output available (so, go ahead and block), + or a 0 if there is more output available (so, just poll the other + sources/destinations, don't block). + */ + +int +DoTerminalOutput() +{ + /* called just before a select to conserve IO to terminal */ + if (!(screenInitd||screenStopped)) { + return 1; /* No output if not initialized */ + } + if ((Lowest <= Highest) || needToRing || + (terminalCursorAddress != CorrectTerminalCursor())) { + TryToSend(); + } + if (Lowest > Highest) { + return 1; /* no more output now */ + } else { + return 0; /* more output for future */ + } +} + +/* + * The following are defined to handle transparent data. + */ + +void +TransStop() +{ + RefreshScreen(); +} + +void +TransOut(buffer, count, kind, control) +unsigned char *buffer; +int count; +int kind; /* 0 or 5 */ +int control; /* To see if we are done */ +{ + char *ptr; + + while (DoTerminalOutput() == 0) { + ; + } + for (ptr = buffer; ptr < buffer+count; ptr++) { + *ptr &= 0x7f; /* Turn off parity bit */ + } + (void) DataToTerminal(buffer, count); + if (control && (kind == 0)) { /* Send in AID byte */ + SendToIBM(); + } else { + TransInput(1, kind); /* Go get some data */ + } +} + +/* + * init_screen() + * + * Initialize variables used by screen. + */ + +void +init_screen() +{ + bellwinup = 0; +} + + diff --git a/usr.bin/tn3270/distribution/sys_dos/termout.ext b/usr.bin/tn3270/distribution/sys_dos/termout.ext new file mode 100644 index 0000000..d3c8fb4 --- /dev/null +++ b/usr.bin/tn3270/distribution/sys_dos/termout.ext @@ -0,0 +1,47 @@ +/*- + * Copyright (c) 1988, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)termout.ext 8.1 (Berkeley) 6/6/93 + */ + +extern void + StartScreen(), + StopScreen(), + ConnectScreen(), + ClearScreen(), + LocalClearScreen(), + RefreshScreen(), + RingBell(), + AddHost(); + +extern int + DoTerminalOutput(); diff --git a/usr.bin/tn3270/distribution/sys_dos/video.h b/usr.bin/tn3270/distribution/sys_dos/video.h new file mode 100644 index 0000000..8fffe6c --- /dev/null +++ b/usr.bin/tn3270/distribution/sys_dos/video.h @@ -0,0 +1,75 @@ +/*- + * Copyright (c) 1988, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)video.h 8.1 (Berkeley) 6/6/93 + */ + +/* + * This is a header file describing the interface via int 10H to the + * video subsystem. + */ + +#define BIOS_VIDEO 0x10 + +typedef enum { + SetMode = 0, + SetCursorType, + SetCursorPosition, + ReadCursorPosition, + ReadLightPenPosition, + SelectActiveDisplayPage, + ScrollActivePageUp, + ScrollActivePageDown, + ReadAttribute_Character, + WriteAttribute_Character, + WriteCharacterOnly, + SetColorPalette, + WriteDot, + ReadDot, + WriteTeletypeToActivePage, + CurrentVideoState, + Reserved16, + Reserved17, + Reserved18, + WriteString +} VideoOperationsType; + +typedef enum { + bw_40x25 = 0, + color_40x25, + bw_80x25, + color_80x25, + color_320x200, + bw_320x200, + bw_640x200, + internal_bw_80x25 +} VideoModeType; diff --git a/usr.bin/tn3270/distribution/telnet/Makefile_ultrix b/usr.bin/tn3270/distribution/telnet/Makefile_ultrix new file mode 100644 index 0000000..dbb93ea --- /dev/null +++ b/usr.bin/tn3270/distribution/telnet/Makefile_ultrix @@ -0,0 +1,179 @@ +# @(#)Makefile 1.4 (Berkeley) 5/15/88 + +# This is the makefile for an Ultrix system. The current Ultrix make(1) doesn't +# support VPATH, so we expand everything out. + +# The following is the telnet makefile for tn3270, using the shared telnet +# sources. + +# +# TERMCAP Define this if your system is termcap based, +# otherwise a terminfo based system is assumed. +# +# SRCRT Includes code to allow you to specify source routes. +# Format is: +# [!]@hop1@hop2...[@|:]dst +# Leading ! means strict source route. +# +# NOSTRNCASECMP Define this if you do not have strncasecmp() in +# your C libarary. +# +# USE_TERMIO Define this if you have System V termio structures. +# What is here is how things are on Cray computers. +# +# KLUDGELINEMODE Define this to get the kludged up version of linemode +# that was in 4.3BSD. This is a good thing to have +# around for talking to older systems. +# + +DEFINES= -DTERMCAP -DSRCRT -DKLUDGELINEMODE + + +VPATH = ../../telnet/Source +XINCLUDES= -I../../telnet/Source +INCLUDES= -I. +XDEFINES = -DTN3270 +OPTIMIZE= -O +CFLAGS = ${OPTIMIZE} ${INCLUDES} ${DEFINES} +XCFLAGS= ${XINCLUDES} ${XDEFINES} +LD = ld +LDFLAGS = -r +PRINT = print +ACTION = sccs tell +LIBC= /lib/libc.a +SD= ../../telnet/Source/ +ALLH= ${SD}defines.h ${SD}externs.h ${SD}fdset.h ${SD}general.h ${SD}ring.h ${SD}types.h +SRCS= ${SD}commands.c ${SD}main.c ${SD}network.c ${SD}ring.c \ + ${SD}sys_bsd.c ${SD}sys_dos.c ${SD}telnet.c ${SD}terminal.c \ + ${SD}tn3270.c ${SD}utilities.c +ALLHC= ${ALLH} ${SRCS} +ALLPRINT = ${ALLHC} +ALLSOURCE= ${ALLHC} Makefile Makefile_ultrix +OBJS= commands.o main.o network.o ring.o sys_bsd.o sys_dos.o \ + telnet.o terminal.o tn3270.o utilities.o + +.c.o: + ${CC} -c ${CFLAGS} ${XCFLAGS} $< + +telprog.o: ${OBJS} ${LIBC} + ${LD} ${LDFLAGS} -o $@ ${OBJS} + +clean: FRC + rm -f ${OBJS} core telnet + +depend: FRC ${SRCS} + mkdep ${CFLAGS} ${SRCS} + +lint: FRC ${SRCS} + lint ${CFLAGS} ${SRCS} + +tags: FRC ${ALLHC} + ctags ${ALLHC} + +print: FRC ${ALLPRINT} + ${PRINT} ${ALLPRINT} + +commands.o: ${SD}commands.c + ${CC} -c ${CFLAGS} ${XCFLAGS} ${SD}commands.c + +main.o: ${SD}main.c + ${CC} -c ${CFLAGS} ${XCFLAGS} ${SD}main.c + +network.o: ${SD}network.c + ${CC} -c ${CFLAGS} ${XCFLAGS} ${SD}network.c + +ring.o: ${SD}ring.c + ${CC} -c ${CFLAGS} ${XCFLAGS} ${SD}ring.c + +sys_bsd.o: ${SD}sys_bsd.c + ${CC} -c ${CFLAGS} ${XCFLAGS} ${SD}sys_bsd.c + +sys_dos.o: ${SD}sys_dos.c + ${CC} -c ${CFLAGS} ${XCFLAGS} ${SD}sys_dos.c + +telnet.o: ${SD}telnet.c + ${CC} -c ${CFLAGS} ${XCFLAGS} ${SD}telnet.c + +terminal.o: ${SD}terminal.c + ${CC} -c ${CFLAGS} ${XCFLAGS} ${SD}terminal.c + +tn3270.o: ${SD}tn3270.c + ${CC} -c ${CFLAGS} ${XCFLAGS} ${SD}tn3270.c + +utilities.o: ${SD}utilities.c + ${CC} -c ${CFLAGS} ${XCFLAGS} ${SD}utilities.c + + +action: FRC + ${ACTION} + +clist: FRC ${SRCS} + @for i in ${SRCS} ; \ + do (echo ${DIRPATH}$$i); done + +hclist: FRC ${ALLHC} + @for i in ${ALLHC} ; \ + do (echo ${DIRPATH}$$i); done + +sourcelist: FRC ${ALLSOURCE} + @for i in ${ALLSOURCE} ../../telnet/Makefile ; \ + do (echo ${DIRPATH}$$i); done + +FRC: + +# DO NOT DELETE THIS LINE -- mkdep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +commands.o: ../../telnet/Source/commands.c /usr/include/sys/types.h +commands.o: /usr/include/sys/socket.h /usr/include/netinet/in.h +commands.o: /usr/include/signal.h /usr/include/machine/trap.h +commands.o: /usr/include/netdb.h /usr/include/ctype.h +commands.o: /usr/include/arpa/telnet.h ../../telnet/Source/ring.h +commands.o: ../../telnet/Source/externs.h /usr/include/stdio.h +commands.o: /usr/include/setjmp.h ../../telnet/Source/defines.h +commands.o: ../../telnet/Source/types.h +main.o: ../../telnet/Source/main.c /usr/include/sys/types.h +main.o: ../../telnet/Source/ring.h ../../telnet/Source/externs.h +main.o: /usr/include/stdio.h /usr/include/setjmp.h +main.o: ../../telnet/Source/defines.h +network.o: ../../telnet/Source/network.c /usr/include/sys/types.h +network.o: /usr/include/sys/socket.h /usr/include/sys/time.h +network.o: /usr/include/time.h /usr/include/errno.h /usr/include/arpa/telnet.h +network.o: ../../telnet/Source/ring.h ../../telnet/Source/defines.h +network.o: ../../telnet/Source/externs.h /usr/include/stdio.h +network.o: /usr/include/setjmp.h ../../telnet/Source/fdset.h +ring.o: ../../telnet/Source/ring.c /usr/include/stdio.h /usr/include/errno.h +ring.o: /usr/include/sys/types.h /usr/include/sys/ioctl.h +ring.o: /usr/include/sys/ttychars.h /usr/include/sys/ttydev.h +ring.o: /usr/include/sys/socket.h ../../telnet/Source/ring.h +ring.o: ../../telnet/Source/general.h +sys_bsd.o: ../../telnet/Source/sys_bsd.c /usr/include/sys/ioctl.h +sys_bsd.o: /usr/include/sys/ttychars.h /usr/include/sys/ttydev.h +sys_bsd.o: /usr/include/sys/types.h /usr/include/sys/time.h /usr/include/time.h +sys_bsd.o: /usr/include/sys/socket.h /usr/include/signal.h +sys_bsd.o: /usr/include/machine/trap.h /usr/include/errno.h +sys_bsd.o: ../../telnet/Source/ring.h ../../telnet/Source/fdset.h +sys_bsd.o: ../../telnet/Source/defines.h ../../telnet/Source/externs.h +sys_bsd.o: /usr/include/stdio.h /usr/include/setjmp.h +sys_bsd.o: ../../telnet/Source/types.h +sys_dos.o: ../../telnet/Source/sys_dos.c +telnet.o: ../../telnet/Source/telnet.c /usr/include/sys/types.h +telnet.o: /usr/include/curses.h /usr/include/stdio.h /usr/include/sgtty.h +telnet.o: /usr/include/sys/ioctl.h /usr/include/sys/ttychars.h +telnet.o: /usr/include/sys/ttydev.h /usr/include/arpa/telnet.h +telnet.o: /usr/include/strings.h ../../telnet/Source/ring.h +telnet.o: ../../telnet/Source/defines.h ../../telnet/Source/externs.h +telnet.o: /usr/include/stdio.h /usr/include/setjmp.h +telnet.o: ../../telnet/Source/types.h ../../telnet/Source/general.h +telnet.o: /usr/include/varargs.h +terminal.o: ../../telnet/Source/terminal.c /usr/include/arpa/telnet.h +terminal.o: /usr/include/sys/types.h ../../telnet/Source/ring.h +terminal.o: ../../telnet/Source/externs.h /usr/include/stdio.h +terminal.o: /usr/include/setjmp.h ../../telnet/Source/types.h +tn3270.o: ../../telnet/Source/tn3270.c ../../telnet/Source/fdset.h +utilities.o: ../../telnet/Source/utilities.c /usr/include/arpa/telnet.h +utilities.o: /usr/include/sys/types.h /usr/include/ctype.h +utilities.o: ../../telnet/Source/ring.h ../../telnet/Source/externs.h +utilities.o: /usr/include/stdio.h /usr/include/setjmp.h + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/usr.bin/tn3270/distribution/ultrix.curses b/usr.bin/tn3270/distribution/ultrix.curses new file mode 100644 index 0000000..f5fcd94 --- /dev/null +++ b/usr.bin/tn3270/distribution/ultrix.curses @@ -0,0 +1,46 @@ +Return-Path: mtxinu!kinetics!minshall@ucbvax.Berkeley.EDU +Received: from ucbvax.berkeley.edu + by violet.berkeley.edu (5.54 (CFC 4.22.3)/1.16.17l) + id AA23846; Wed, 30 Mar 88 19:54:24 PST +Received: by ucbvax.berkeley.edu (5.59/1.26) + id AA09851; Tue, 29 Mar 88 23:25:19 PST +Received: by mtxinu.UUCP (5.51/4.7) + id AA05135; Tue, 29 Mar 88 17:32:01 PST +Message-Id: <8803300132.AA05135@mtxinu.UUCP> +Date: Thu, 17 Mar 88 11:06:10 pst +From: mtxinu!kinetics!minshall@ucbvax.Berkeley.EDU (Greg Minshall) +To: mtxinu!minshall + +Path: kinetics!zehntel!varian!ptsfa!pacbell!ames!ll-xn!husc6!panda!teddy!jpn +From: jpn@teddy.UUCP (John P. Nelson) +Newsgroups: comp.bugs.4bsd +Subject: Re: Ultrix curses problem +Keywords: curses ultrix bug fix +Message-ID: <4668@teddy.UUCP> +Date: 14 Mar 88 19:43:39 GMT +References: <535@hscfvax.harvard.edu> +Reply-To: jpn@teddy.UUCP (John P. Nelson) +Organization: GenRad, Inc., Concord, Mass. +Lines: 21 + +>I have found the bug, fixable as above, in both Ultrix 1.2 and 2.0. Feedback +>from those brave souls who have brought up 2.2 would be most welcome. + +Yup, the bug exists in Ultrix 2.2 as well. I have reported this bug to +DEC support every time we get a new release. I assume that my bug reports +are getting filed (in the circular file). + +It is clear that whoever made this "fix" at DEC had no understanding +of curses whatsoever. As in the earlier posting, the bug can be fixed +by replacing the definitions of the nl() and nonl() macros in curses.h with: + +#define nl() (_tty.sg_flags |= CRMOD,_pfast = _rawmode,stty(_tty_ch, &_tty)) +#define nonl() (_tty.sg_flags &= ~CRMOD, _pfast = TRUE, stty(_tty_ch, &_tty)) + +- john nelson. + +P.S. I did reach someone at DEC who would listen (Thanks Chet!) My + understanding is that they have no plans to fix this bug, as curses + is now "owned" by some group in England, who is working on a port of the + terminfo curses for Ultrix 2.4. I'm just pissed that my bug reports + submitted for Ultrix 1.2 and 2.0 were ignored. diff --git a/usr.bin/tn3270/distribution/utilities/adm3a.keys b/usr.bin/tn3270/distribution/utilities/adm3a.keys new file mode 100644 index 0000000..4e65374 --- /dev/null +++ b/usr.bin/tn3270/distribution/utilities/adm3a.keys @@ -0,0 +1,78 @@ +1LSI ADM 3A Key Definitions for IBM 3277 Terminal Emulation 06/18/81 ++LSI ADM 3A Key Definitions for IBM 3277 Terminal Emulation 06/18/81 + + 3277 Key ADM Key(s) | 3277 Key LSI ADM 3A Key(s) + ======== ========== | ======== ==================== + | + Cursor Movement Keys | Command Keys ++______ ________ ____ _______ ____ + | + New Line Ctrl-N -or- | Enter Return + Home | Clear Ctrl-Z + Tab Ctrl-I | + Back Tab Ctrl-B | Program Function Keys ++ _______ ________ ____ + Cursor Left Ctrl-H | + Cursor Right Ctrl-L | PF1 Esc 1 + Cursor Up Ctrl-K | PF2 Esc 2 + Cursor Down Ctrl-J -or- | PF3 Esc 3 + Line Feed | PF4 Esc 4 + Home Ctrl-@ | PF5 Esc 5 + | PF6 Esc 6 + | PF7 Esc 7 + Edit Control Keys | PF8 Esc 8 ++____ _______ ____ + | PF9 Esc 9 + Delete Char Ctrl-D -OR- Rub | PF10 Esc 0 + Erase EOF Ctrl-E | PF11 Esc Colon + Erase Input Ctrl-W | PF12 Esc Minus + Insert Mode Esc Space | PF13 Ctrl-F 1 3 + End Insert Esc Space | PF14 Ctrl-F 1 4 + Dup Ctrl-U | PF15 Ctrl-F 1 5 + Field Mark Ctrl-Y | PF16 Ctrl-F 1 6 + | PF17 Ctrl-F 1 7 + Series-1 Control Keys | PF18 Ctrl-F 1 8 ++________ _______ ____ + | PF19 Ctrl-F 1 9 + Reset After Error Ctrl-R | PF20 Ctrl-F 2 0 + Keyboard Unlock Ctrl-T | PF21 Ctrl-F 2 1 + Purge Input Buffer Ctrl-X | PF22 Ctrl-F 2 2 + Stop Output Ctrl-S | PF23 Ctrl-F 2 3 + Start Output Ctrl-Q | PF24 Ctrl-F 2 4 + Re-Display Screen Ctrl-V | + | Program Attention Keys ++ _______ _________ ____ + Miscellaneous 3277 Keys | ++_____________ ____ ____ + | PA1 Ctrl-P 1 + Cursor Select Esc Period | PA2 Ctrl-P 2 + Test Request (not supported) | PA3 Ctrl-P 3 + + Series 1 Local Editing Keys ++______ _ _____ _______ ____ + + Set Tab Stop Esc Semicolon + Clear (all) Tab Stops Esc Plus + Set Left Margin (New Line) Esc LeftParen + Set Home (Home) Esc Exclamation + Tab to Next Local Tab Stop Esc i (or Esc I) + Tab to Previous Local Tab Stop Esc b (or Esc B) + Indent (to Next Local Tab Stop - New Line) Esc l (or Esc L) + Undent (to Previous Local Tab Stop - New Line) Esc h (or Esc H) + + + Note: If the terminal hangs up, enter "Ctrl-H" and see if the + cursor moves. If it does, you are trying to enter data + into a protected field, trying to insert a character when + the last character of the field is non-blank, or trying to + communicate to a virtual process which is not accepting data. + If the cursor did not move, a transmission error or terminal + lock has occurred. Enter the following sequence to unhang + the terminal: "Ctrl-R Ctrl-T Ctrl-X Ctrl-Q Ctrl-V". + + ********** DRAFT ONLY - SPECIFICATION SUBJECT TO CHANGE ********** ++********** DRAFT ONLY - SPECIFICATION SUBJECT TO CHANGE ********** ++********** DRAFT ONLY - SPECIFICATION SUBJECT TO CHANGE ********** ++********** DRAFT ONLY - SPECIFICATION SUBJECT TO CHANGE ********** + + diff --git a/usr.bin/tn3270/distribution/utilities/cross.c b/usr.bin/tn3270/distribution/utilities/cross.c new file mode 100644 index 0000000..191aac0 --- /dev/null +++ b/usr.bin/tn3270/distribution/utilities/cross.c @@ -0,0 +1,55 @@ +/* + This program is, essentially, a cross product generator. It takes + an input file which is said to consist of a number of lines, and + expands each line. A line like + (a,b)(c,d) + will be expanded to lines like + ac + ad + bc + bd + (without regard for the ORDER of the output; ie: the lines can appear + in any order). + + Parenthesis can be nested, so + (a,b)(c(d,e),f) + will produce + acd + ace + af + bcd + bce + bf + */ + + +#include <stdio.h> + +char leftParen, /* The left parenthesis character */ + rightParen; /* The right parenthesis character */ + + +/* Finds next occurrence of 'character' at this level of nesting. + Returns 0 if no such character found. + */ + +char * +ThisLevel(string, character) +char *string, character; +{ + int level; /* Level 0 is OUR level */ + + level = 0; + + while (*string != '\0') { + if (*string == leftParen) + level++; + else if (*string == rightParen) { + level--; + if (level < 0) + return(0); + } + if ((level == 0) && (*string == character)) + return(string); + string++; + } diff --git a/usr.bin/tn3270/distribution/utilities/makefile b/usr.bin/tn3270/distribution/utilities/makefile new file mode 100644 index 0000000..0cb5b3e --- /dev/null +++ b/usr.bin/tn3270/distribution/utilities/makefile @@ -0,0 +1,121 @@ +# +# Copyright (c) 1988 Regents of the University of California. +# All rights reserved. +# +# Redistribution and use in source and binary forms are permitted +# provided that the above copyright notice and this paragraph are +# duplicated in all such forms and that any documentation, +# advertising materials, and other materials related to such +# distribution and use acknowledge that the software was developed +# by the University of California, Berkeley. The name of the +# University may not be used to endorse or promote products derived +# from this software without specific prior written permission. +# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED +# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. +# +# @(#)makefile 8.1 (Berkeley) 6/6/93 +# +# msdos versus unix defines +O = .o +#PC_O = .obj + +X = +#PC_X = .exe + +L = +#PC_L = -link + +CC = cc +#PC_CC = cl + +MV = mv +#PC_MV = rename + +RM = rm -f +#PC_RM= erase + +LINT_ARGS = +#PC_LINT_ARGS = -DLINT_ARGS + +DEBUG_FLAGS = -g +#PC_DEBUG_FLAGS = -Zi -Od + +AR = ar +AR1 = cr +AR2 = +AR3 = +#PC_AR = lib +#PC_AR1 = +#PC_AR2 = + +#PC_AR3 = ";" + +RANLIB = ranlib +#PC_RANLIB = echo "Done with " + +DEFINES = ${LINT_ARGS} + +CFLAGS = ${DEBUG_FLAGS} -I.. + +PRINT = lpr -p + +ALLC = tnrecv.c +ALLH = tncomp.h + +ALLPRINT = ${ALLH} ${ALLC} + +ALLSOURCE = ${ALLPRINT} makefile makefile.mak + +ALLO = tnrecv$O + +.c.obj: + ${CC} ${CFLAGS} -c $< + +all: tnrecv$X + +tnrecv$X: tnrecv$O + ${CC} ${CFLAGS} -o $@ tnrecv$O $L ../api/apilib.a + +clean: + for i in makefile.bak ${ALLO} errs tnrecv$X; \ + do (${RM} $$i); done + +.DEFAULT: + sccs get $< + +sccsclean: + -sccs clean + -sccs get makefile + +action: + ${ACTION} + +print: + ${PRINT} ${ALLPRINT} + +sourcelist: ${ALLSOURCE} tarread.exe + @for i in ${ALLSOURCE} tarread.exe; \ + do (echo ${DIRPATH}$$i); done + +depend: + grep '^#include' ${ALLC} | grep -v '<' | \ + sed -e 's/:[^"]*"\([^"]*\)".*/: \1/' \ + -e 's/\.c/$$O/' | \ + awk ' { if ($$1 != prev) { print rec; rec = $$0; prev = $$1; } \ + else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \ + else rec = rec " " $$2 } } \ + END { print rec } ' > makedep + echo '$$r makedep' >>eddep + echo '/^# DO NOT DELETE THIS LINE/+1,$$d' >eddep + echo '$$r makedep' >>eddep + echo 'w' >>eddep + -rm -f makefile.bak + cp makefile makefile.bak + ed - makefile < eddep + rm eddep makedep + +# DO NOT DELETE THIS LINE + +#include "tncomp.h" "../api/api.h" "../ctlr/function.h" "../ctlr/hostctlr.h" +#include "../ctlr/oia.h" "../ctlr/screen.h" "../apilib/disp_asc.h" +#include "../apilib/astosc.h" "../general/general.h" diff --git a/usr.bin/tn3270/distribution/utilities/srccmd/tar/makefile b/usr.bin/tn3270/distribution/utilities/srccmd/tar/makefile new file mode 100644 index 0000000..f4618af --- /dev/null +++ b/usr.bin/tn3270/distribution/utilities/srccmd/tar/makefile @@ -0,0 +1,8 @@ +tarread.obj: tarread.c + cl /c /Zd tarread.c + +tarread.exe: tarread.obj + link tarread,,tarread/map/lin; + +tarread.sym: tarread.map + mapsym /l tarread diff --git a/usr.bin/tn3270/distribution/utilities/srccmd/tar/tar.h b/usr.bin/tn3270/distribution/utilities/srccmd/tar/tar.h new file mode 100644 index 0000000..0345756 --- /dev/null +++ b/usr.bin/tn3270/distribution/utilities/srccmd/tar/tar.h @@ -0,0 +1,19 @@ +/* tar.h */ + +#define TBLOCK 512 +#define NAMSIZ 100 + +union hblock { + char dummy[TBLOCK]; + struct header { + char name[NAMSIZ]; + char mode[8]; + char gid[8]; + char uid[8]; + char size[12]; + char mtime[12]; + char chksum[8]; + char linkflag; + char linkname[NAMSIZ]; + } dbuf; +}; diff --git a/usr.bin/tn3270/distribution/utilities/srccmd/tar/tarread.c b/usr.bin/tn3270/distribution/utilities/srccmd/tar/tarread.c new file mode 100644 index 0000000..fedeb69 --- /dev/null +++ b/usr.bin/tn3270/distribution/utilities/srccmd/tar/tarread.c @@ -0,0 +1,208 @@ +/* tarread.c */ +/* Copyright (c) 1985, by Carnegie-Mellon University */ + +#include <stdio.h> +#include <v2tov3.h> +#include <sys\types.h> +#include <sys\stat.h> +#include "tar.h" + +char usage[] = "tarread: usage: tarread tx[vwz] tarfile\n"; +union hblock hbuf; + +int verbose = 0; +int confirm = 0; +int binary = 0; +char cmd; + +main(argc, argv) +int argc; +char *argv[]; +{ + FILE *fp; + char *cp; + + if (argc != 3) { + fprintf(stderr, usage); + exit(1); + } + + for (cp = argv[1]; *cp; cp++) + switch (*cp) { + case 't': + case 'x': + cmd = *cp; + break; + + case 'v': + verbose++; + break; + case 'z': + binary++; + break; + case 'w': + confirm++; + break; + default: + fprintf(stderr, "tarread: unknown switch %c\n", *cp); + fprintf(stderr, usage); + exit(1); + } + + if ((fp = fopen(argv[2], "rb")) == NULL) { + fprintf(stderr, "tarrread: cannot open %s\n", argv[2]); + exit(1); + } + + for (;;) { + if (fread(&hbuf, sizeof(hbuf), 1, fp) != 1) { + perror("fread"); + exit(1); + } + if (!proc_file(fp)) + break; + } +} + + +int proc_file(fp) +FILE *fp; +{ + char name[NAMSIZ]; + unsigned short mode; + short uid, gid; + long size, mtime; + char c; + int confrmd; + long skip; + + if (hbuf.dbuf.name[0] == '\0') + return (NULL); + + strcpy(name, hbuf.dbuf.name); + if (sscanf(hbuf.dbuf.mode, "%o", &mode) != 1) + fprintf("Couldn't read mode\n"); + if (sscanf(hbuf.dbuf.uid, "%o", &uid) != 1) + fprintf("Couldn't read uid\n"); + if (sscanf(hbuf.dbuf.gid, "%o", &gid) != 1) + fprintf("Couldn't read gid\n"); + if (sscanf(hbuf.dbuf.size, "%12lo %12lo", &size, &mtime) != 2) + fprintf("Couldn't read size or mtime\n"); + + skip = (size + TBLOCK - 1) / TBLOCK * TBLOCK; + + switch (cmd) { + case 't': + if (verbose) + printf("%8o %d/%d\t %6ld %.24s %s\n", mode, + uid, gid, size, ctime(&mtime), name); + else + printf("%s\n", name); + + break; + + case 'x': + if (verbose) + printf("x %s: ", name); + confrmd = 1; + + if (confirm) { + confrmd = 0; + if ((c = getchar()) == 'y') + confrmd++; + while (c != '\n') + c = getchar(); + if(!confrmd) + break; + } + + if(extract(name, size, mode, mtime, fp)) + skip = 0; + + if (verbose) + printf("\n"); + break; + } + if (fseek(fp, skip, 1)) { + perror("fseek"); + exit(1); + } + return (1); +} + + +int extract(fname, size, mode, mtime, ifp) +char *fname; +long size; +unsigned short mode; +long mtime; +FILE *ifp; +{ + FILE *ofp; + char fbuf[TBLOCK]; + long copied, left; + char *s, *np, *strchr(); + struct stat sbuf; + + for(np = fname; s = strchr(np, '/'); np = s+1) { + *s = '\0'; + if(stat(fname, &sbuf)) { + if(mkdir(fname)) + perror("mkdir"); + } else if(!(sbuf.st_mode & S_IFDIR)) { + fprintf(stderr, "\n%s: Not a directory", fname); + *s = '/'; + fprintf(stderr, "\ntar: %s - cannot create", fname); + return (0); + } + *s = '/'; + } + if(!*np) + return (0); + + if (binary) { + if ((ofp = fopen(fname, "wb")) == NULL) { + perror("extract:"); + return (0); + } + } else { + if ((ofp = fopen(fname, "w")) == NULL) { + perror("extract:"); + return (0); + } + } + + for(copied = 0; copied < size; copied += TBLOCK) { + if(fread(fbuf, TBLOCK, 1, ifp) != 1) { + perror("fread"); + exit(1); + } + left = size - copied; + if(fwrite(fbuf, (int)min(left, TBLOCK), 1, ofp) != 1) { + perror("fwrite"); + exit(1); + } + } + + if(fclose(ofp)) { + perror("fclose"); + exit(1); + } + + /* + * Now, set modification time. + */ + { +#include <sys\utime.h> + struct utimbuf utim; + + utim.modtime = mtime; + + if (utime(fname, &utim) == -1) { + perror("utime"); + exit(1); + } + } + + return (1); +} diff --git a/usr.bin/tn3270/distribution/utilities/tncomp.h b/usr.bin/tn3270/distribution/utilities/tncomp.h new file mode 100644 index 0000000..c726297 --- /dev/null +++ b/usr.bin/tn3270/distribution/utilities/tncomp.h @@ -0,0 +1,51 @@ +/*- + * Copyright (c) 1988, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)tncomp.h 8.1 (Berkeley) 6/6/93 + */ + +/* + * Where the fields fall on the formatted screen used by tncomp, tnrecv, + * and tnsend. + */ + +#define SEND_SEQUENCE 1 +#define SEND_SEQUENCE_LENGTH 23 + +#define ACK_SEQUENCE (SEND_SEQUENCE+SEND_SEQUENCE_LENGTH+1) +#define ACK_SEQUENCE_LENGTH 22 + +#define CHECKSUM (ACK_SEQUENCE+ACK_SEQUENCE_LENGTH+1) +#define CHECKSUM_LENGTH 32 + +#define DATA (CHECKSUM+CHECKSUM_LENGTH+1) +#define DATA_LENGTH ((80*22)+79) diff --git a/usr.bin/tn3270/distribution/utilities/tnrecv.c b/usr.bin/tn3270/distribution/utilities/tnrecv.c new file mode 100644 index 0000000..4474691 --- /dev/null +++ b/usr.bin/tn3270/distribution/utilities/tnrecv.c @@ -0,0 +1,674 @@ +/*- + * Copyright (c) 1988, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char copyright[] = +"@(#) Copyright (c) 1988, 1993\n\ + The Regents of the University of California. All rights reserved.\n"; +#endif /* not lint */ + +#ifndef lint +static char sccsid[] = "@(#)tnrecv.c 8.1 (Berkeley) 6/6/93"; +#endif /* not lint */ + +#include <stdio.h> + +#include <api/apilib.h> + +#include "tncomp.h" + + +#include "../ctlr/api.h" +#include "../ctlr/function.h" +#include "../ctlr/hostctlr.h" +#include "../ctlr/oia.h" +#include "../ctlr/screen.h" + +#include "../api/disp_asc.h" +#include "../api/astosc.h" + +#include "../general/general.h" + +ScreenImage Host[MAXSCREENSIZE]; + +static char + a_send_sequence[SEND_SEQUENCE_LENGTH+1], + a_ack_sequence[ACK_SEQUENCE_LENGTH+1], + a_checksum[CHECKSUM_LENGTH+1], + data_array[DATA_LENGTH+1]; + +static int + verbose, + blocks, + enter_index, + clear_index, + ScreenSize, + session_id; + +static unsigned int + send_sequence, + ack_sequence = -1, + checksum; + +api_perror(string) +char *string; +{ + fprintf(stderr, "Error: [0x%x/0x%x:0x%x/0x%x] from %s.\n", + api_sup_fcn_id, api_sup_errno, + api_fcn_fcn_id, api_fcn_errno, string); +} + + +char * +session_type(type) +int type; +{ + switch (type) { + case TYPE_WSCTL: + return "work station control"; + case TYPE_DFT: + return "distributed function terminal"; + case TYPE_CUT: + return "control unit terminal"; + case TYPE_NOTEPAD: + return "notepad"; + case TYPE_PC: + return "personal computer"; + default: + return "(UNKNOWN)"; + } +} + +static int +wait_for_ps_or_oia() +{ +#if defined(unix) + return api_ps_or_oia_modified(); +#endif /* defined(unix) */ +} + + +static int +wait_for_unlock() +{ + OIA oia; + ReadOiaGroupParms re; + static char zeroes[sizeof oia.input_inhibited] = { 0 }; + + do { + re.rc = re.function_id = 0; + re.session_id = session_id; + re.oia_buffer = (char far *) &oia; + re.oia_group_number = API_OIA_ALL_GROUPS; + if (api_read_oia_group(&re) == -1) { + api_perror("api_read_oia_group"); + return -1; + } else if (verbose) { + if (IsOiaReady3274(&oia)) { + printf("3274 ready, "); + } + if (IsOiaMyJob(&oia)) { + printf("my job, "); + } + if (IsOiaInsert(&oia)) { + printf("insert mode, "); + } + if (IsOiaSystemLocked(&oia)) { + printf("system locked, "); + } + if (IsOiaTWait(&oia)) { + printf("terminal wait, "); + } + printf("are some bits from the OIA.\n"); + } + /* We turned this on, so turn it off now */ + ResetOiaApiInhibit(&oia); + if (memcmp(zeroes, oia.input_inhibited, sizeof oia.input_inhibited)) { + if (wait_for_ps_or_oia() == -1) { + return -1; + } + } + } while (memcmp(zeroes, oia.input_inhibited, sizeof oia.input_inhibited)); + return 0; +} + +static int +initialize() +{ + QuerySessionIdParms id; + QuerySessionParametersParms pa; + QuerySessionCursorParms cu; + ConnectToKeyboardParms conn; + DisableInputParms disable; + NameArray namearray; + + if (api_init() == 0) { + fprintf(stderr, "API function not available.\n"); + return -1; + } + + id.rc = 0; + id.function_id = 0; + id.option_code = ID_OPTION_BY_NAME; + id.data_code = 'E'; + id.name_array = &namearray; + namearray.length = sizeof namearray; + if (api_query_session_id(&id)) { + api_perror("api_query_session_id"); + } else if (namearray.number_matching_session == 0) { + fprintf(stderr, "query_session_id: No matching sessions!\n"); + return -1; + } else if (verbose) { + printf("Session short name 0x%x, type is ", + namearray.name_array_element.short_name); + printf("%s", session_type(namearray.name_array_element.type)); + printf(", session ID is: 0x%x\n", + namearray.name_array_element.session_id); + } + session_id = namearray.name_array_element.session_id; + + pa.rc = pa.function_id = 0; + pa.session_id = session_id; + if (api_query_session_parameters(&pa) == -1) { + api_perror("api_query_session_parameters"); + return -1; + } else if (verbose) { + printf("Session type %s, ", session_type(pa.session_type)); + if (pa.session_characteristics&CHARACTERISTIC_EAB) { + printf(" has EAB, "); + } + if (pa.session_characteristics&CHARACTERISTIC_PSS) { + printf(" has PSS, "); + } + printf("%d rows, %d columns ", pa.rows, pa.columns); + if (pa.presentation_space) { + printf("presentation space at 0x%x:0x%x.\n", + FP_SEG(pa.presentation_space), FP_OFF(pa.presentation_space)); + } else { + printf("(no direct presentation space access).\n"); + } + } + ScreenSize = pa.rows*pa.columns; + if (pa.session_characteristics&CHARACTERISTIC_EAB) { + fprintf(stderr, + "tncomp utilities not designed to work with extended attribute buffers.\n"); + return -1; + } + + if (verbose) { + cu.rc = cu.function_id = 0; + cu.session_id = session_id; + if (api_query_session_cursor(&cu) == -1) { + api_perror("api_query_session_cursor"); + } else { + printf("cursor"); + if (cu.cursor_type&CURSOR_INHIBITED_AUTOSCROLL) { + printf(" inhibited autoscroll"); + } + if (cu.cursor_type&CURSOR_INHIBITED) { + printf(" inhibited"); + } + if (cu.cursor_type&CURSOR_BLINKING) { + printf(" blinking"); + } else { + printf(" not blinking"); + } + if (cu.cursor_type&CURSOR_BOX) { + printf(" box "); + } else { + printf(" not box "); + } + printf("at row %d, column %d.\n", + cu.row_address, cu.column_address); + } + } + + conn.rc = conn.function_id = 0; + conn.session_id = session_id; + conn.event_queue_id = conn.input_queue_id = 0; + conn.intercept_options = 0; + if (api_connect_to_keyboard(&conn) == -1) { + api_perror("api_connect_to_keyboard"); + } else if (verbose) { + if (conn.first_connection_identifier) { + printf("First keyboard connection.\n"); + } else { + printf("Not first keyboard connection.\n"); + } + } + + disable.rc = disable.function_id = 0; + disable.session_id = session_id; + disable.connectors_task_id = 0; + if (api_disable_input(&disable) == -1) { + api_perror("api_disable_input"); + return -1; + } else if (verbose) { + printf("Disabled.\n"); + } + + if ((enter_index = ascii_to_index("ENTER")) == -1) { + return -1; + } + if ((clear_index = ascii_to_index("CLEAR")) == -1) { + return -1; + } + + return 0; /* all ok */ +} + +static int +send_key(index) +int index; +{ + WriteKeystrokeParms wr; + extern struct astosc astosc[]; + + wait_for_unlock(); + + wr.rc = wr.function_id = 0; + wr.session_id = session_id; + wr.connectors_task_id = 0; + wr.options = OPTION_SINGLE_KEYSTROKE; + wr.number_of_keys_sent = 0; + wr.keystroke_specifier.keystroke_entry.scancode = astosc[index].scancode; + wr.keystroke_specifier.keystroke_entry.shift_state + = astosc[index].shiftstate; + if (api_write_keystroke(&wr) == -1) { + api_perror("api_write_keystroke"); + return -1; + } else if (wr.number_of_keys_sent != 1) { + fprintf(stderr, "write_keystroke claims to have sent %d keystrokes.\n", + wr.number_of_keys_sent); + return -1; + } else if (verbose) { + printf("Keystroke sent.\n"); + } + if (wait_for_ps_or_oia() == -1) { + return -1; + } + return 0; +} + +static int +terminate() +{ + EnableInputParms enable; + DisconnectFromKeyboardParms disc; + + enable.rc = enable.function_id = 0; + enable.session_id = session_id; + enable.connectors_task_id = 0; + if (api_enable_input(&enable) == -1) { + api_perror("api_enable"); + return -1; + } else if (verbose) { + printf("Enabled.\n"); + } + + disc.rc = disc.function_id = 0; + disc.session_id = session_id; + disc.connectors_task_id = 0; + if (api_disconnect_from_keyboard(&disc) == -1) { + api_perror("api_disconnect_from_keyboard"); + return -1; + } else if (verbose) { + printf("Disconnected from keyboard.\n"); + } + + (void) api_finish(); + + return 0; +} + + +static int +get_screen() +{ + CopyStringParms copy; + /* Time copy services */ + + wait_for_unlock(); + + copy.copy_mode = 0; + copy.rc = copy.function_id = 0; + copy.source.session_id = session_id; + copy.source.buffer = 0; + copy.source.characteristics = 0; + copy.source.session_type = TYPE_DFT; + copy.source.begin = 0; + + copy.source_end = ScreenSize; + + copy.target.session_id = 0; + copy.target.buffer = (char *) &Host[0]; + copy.target.characteristics = 0; + copy.target.session_type = TYPE_DFT; + + if (api_copy_string(©) == -1) { + api_perror("api_copy_string"); + return -1; + } + return 0; +} + + +put_at(offset, from, length, attribute) +int offset; +char *from; +int length; +{ + CopyStringParms copy; + + wait_for_unlock(); + + copy.copy_mode = 0; + copy.rc = copy.function_id = 0; + copy.source.session_id = 0; + copy.source.buffer = from; + copy.source.characteristics = 0; + copy.source.session_type = TYPE_DFT; + copy.source.begin = 0; + + copy.source_end = length-1; + + copy.target.session_id = session_id; + copy.target.buffer = 0; + copy.target.characteristics = 0; + copy.target.session_type = TYPE_DFT; + copy.target.begin = offset; + + if (api_copy_string(©) == -1) { + api_perror("api_copy_string"); + return -1; + } + return 0; +} + +static void +translate(input, output, table, length) +char *input, *output, table[]; +int length; +{ + unsigned char *indices = (unsigned char *) input; + + while (length--) { + *output++ = table[*indices++]; + } +} + +static int +find_input_area(from) +int from; +{ +#define FieldDec(p) (0) /* We don't really use this */ + register int i, attr; + + for (i = from; i < MAXSCREENSIZE; ) { + if (IsStartField(i)) { + attr = FieldAttributes(i); + i++; + if (!IsProtectedAttr(i, attr)) { + return i; + } + } else { + i++; + } + } + return -1; +} + + +static void +getascii(offset, to, length) +int offset; /* Where in screen */ +char *to; /* Where it goes to */ +int length; /* Where to put it */ +{ + translate(Host+offset, to, disp_asc, length); +} + +static int +putascii(offset, from, length, before) +int offset; /* Where in screen */ +char *from; /* Where it comes from */ +int length; /* Where to put it */ +int before; /* How much else should go */ +{ + translate(from, Host+offset, asc_disp, length); + if (put_at(offset-before, + (char *) Host+offset-before, length+before) == -1) { + return -1; + } + return 0; +} + +static int +ack() +{ + static char ack_blanks[sizeof a_ack_sequence] = {0}; + + if (ack_blanks[0] == 0) { + int i; + + for (i = 0; i < sizeof ack_blanks; i++) { + ack_blanks[i] = ' '; + } + } + + memcpy(a_ack_sequence, ack_blanks, sizeof a_ack_sequence); + sprintf(a_ack_sequence, "%d", ack_sequence); + a_ack_sequence[strlen(a_ack_sequence)] = ' '; + if (putascii(ACK_SEQUENCE, a_ack_sequence, ACK_SEQUENCE_LENGTH, 0) == -1) { + return -1; + } + return 0; +} + +static int +formatted_correct() +{ + if ((find_input_area(SEND_SEQUENCE-1) != SEND_SEQUENCE) || + (find_input_area(SEND_SEQUENCE) != ACK_SEQUENCE) || + (find_input_area(ACK_SEQUENCE) != CHECKSUM) || + (find_input_area(CHECKSUM) != DATA)) { + return -1; + } else { + return 0; + } +} + + +main(argc, argv) +int argc; +char *argv[]; +{ + register int i; + int data_length, input_length; + char ascii[8]; /* Lots of room */ + FILE *outfile; + char *data; + char *argv0 = argv[0]; + + argc--; + argv++; + /* Process any flags */ + while (argc && (argv[0][0] == '-')) { + switch (argv[0][1]) { + case 'v': + verbose = 1; + break; + case 'b': + blocks = 1; + break; + } + argc--; + argv++; + } + + if ((argc) < 2) { + fprintf(stderr, + "usage: %s [-b] [-v] local.file remote.file [remote.options]\n", + argv0); + exit(1); + } + + /* Open the local file */ + if ((outfile = fopen(argv[0], "w")) == NULL) { + perror("fopen"); + exit(2); + } + argc--; + argv++; + + if (initialize() == -1) { + return -1; + } + + /* build the command line */ + data = data_array; + strcpy(data, "TNCOMP SEND"); + data += strlen(data); + while (argc--) { + *data++ = ' '; + strcpy(data, argv[0]); + data += strlen(argv[0]); + argv++; + } + if (verbose) { + printf("%s\n", data_array); + } + if (get_screen() == -1) { + return -1; + } + data_length = strlen(data_array); + if ((i = find_input_area(0)) == -1) { /* Get an input area */ + if (send_key(clear_index) == -1) { + return -1; + } + if ((i = find_input_area(0)) == -1) { /* Try again */ + fprintf(stderr, "Unable to enter command line.\n"); + return -1; + } + } + if (putascii(i, data_array, data_length, 0) == -1) { + return -1; + } + if (send_key(enter_index) == -1) { + return -1; + } + do { + if (get_screen() == -1) { + return -1; + } + } while (formatted_correct() == -1); + + do { + if (get_screen() == -1) { + return -1; + } + /* For each screen */ + if (formatted_correct() == -1) { + fprintf(stderr, "Bad screen written by host.\n"); + return -1; + } + /* If MDT isn't reset in the sequence number, go around again */ + if (Host[ACK_SEQUENCE-1]&ATTR_MDT) { + if (wait_for_ps_or_oia() == -1) { + return -1; + } + continue; + } + getascii(SEND_SEQUENCE, a_send_sequence, SEND_SEQUENCE_LENGTH); + send_sequence = atoi(a_send_sequence); + getascii(CHECKSUM, a_checksum, CHECKSUM_LENGTH); + checksum = atoi(a_checksum); + getascii(DATA, data_array, DATA_LENGTH); + data = data_array; + if (send_sequence != (ack_sequence+1)) { + if (ack() == -1) { + return -1; + } + data = "1234"; /* Keep loop from failing */ + if (send_key(enter_index) == -1) { + return -1; + } + if (get_screen() == -1) { + return -1; + } + continue; + } + + data_length = DATA_LENGTH; + while (data_length && memcmp(data, " EOF", 4) + && memcmp(data, " ", 4)) { + memcpy(ascii, data, 4); + data += 4; + data_length -= 4; + ascii[4] = 0; + input_length = atoi(ascii); + /* CMS can't live with zero length records */ + if ((input_length > 1) || + ((input_length == 1) && (data[0] != ' '))) { + if (fwrite(data, sizeof (char), + input_length, outfile) == 0) { + perror("fwrite"); + exit(9); + } + } + fprintf(outfile, "\n"); + data += input_length; + data_length -= input_length; + } + + ack_sequence = send_sequence; + if (blocks) { + printf("#"); + fflush(stdout); + } + if (ack() == -1) { + return -1; + } + if (send_key(enter_index) == -1) { + return -1; + } + } while (memcmp(data, " EOF", 4)); + + if (blocks) { + printf("\n"); + } + if (terminate() == -1) { + return -1; + } + return 0; +} |