New Telnet Client
authorSteven Edwards <winehacker@gmail.com>
Sun, 30 Dec 2001 10:05:48 +0000 (10:05 +0000)
committerSteven Edwards <winehacker@gmail.com>
Sun, 30 Dec 2001 10:05:48 +0000 (10:05 +0000)
svn path=/trunk/; revision=2458

57 files changed:
rosapps/net/telnet/Makefile [new file with mode: 0644]
rosapps/net/telnet/Makefile.mingw [new file with mode: 0644]
rosapps/net/telnet/doc/00readme.avs [new file with mode: 0644]
rosapps/net/telnet/doc/bugs.txt [new file with mode: 0644]
rosapps/net/telnet/doc/changes.txt [new file with mode: 0644]
rosapps/net/telnet/doc/license.txt [new file with mode: 0644]
rosapps/net/telnet/doc/options.txt [new file with mode: 0644]
rosapps/net/telnet/doc/readme.txt [new file with mode: 0644]
rosapps/net/telnet/doc/ssh.txt [new file with mode: 0644]
rosapps/net/telnet/resource/tnmsg.h [new file with mode: 0644]
rosapps/net/telnet/resource/tnmsg.rc [new file with mode: 0644]
rosapps/net/telnet/src/ansiprsr.cpp [new file with mode: 0644]
rosapps/net/telnet/src/ansiprsr.h [new file with mode: 0644]
rosapps/net/telnet/src/keytrans.cpp [new file with mode: 0644]
rosapps/net/telnet/src/keytrans.h [new file with mode: 0644]
rosapps/net/telnet/src/stl_bids.h [new file with mode: 0644]
rosapps/net/telnet/src/tcharmap.cpp [new file with mode: 0644]
rosapps/net/telnet/src/tcharmap.h [new file with mode: 0644]
rosapps/net/telnet/src/tconsole.cpp [new file with mode: 0644]
rosapps/net/telnet/src/tconsole.h [new file with mode: 0644]
rosapps/net/telnet/src/telnet.h [new file with mode: 0644]
rosapps/net/telnet/src/tkeydef.cpp [new file with mode: 0644]
rosapps/net/telnet/src/tkeydef.h [new file with mode: 0644]
rosapps/net/telnet/src/tkeymap.cpp [new file with mode: 0644]
rosapps/net/telnet/src/tkeymap.h [new file with mode: 0644]
rosapps/net/telnet/src/tmapldr.cpp [new file with mode: 0644]
rosapps/net/telnet/src/tmapldr.h [new file with mode: 0644]
rosapps/net/telnet/src/tmouse.cpp [new file with mode: 0644]
rosapps/net/telnet/src/tmouse.h [new file with mode: 0644]
rosapps/net/telnet/src/tnclass.cpp [new file with mode: 0644]
rosapps/net/telnet/src/tnclass.h [new file with mode: 0644]
rosapps/net/telnet/src/tnclip.cpp [new file with mode: 0644]
rosapps/net/telnet/src/tnclip.h [new file with mode: 0644]
rosapps/net/telnet/src/tncon.cpp [new file with mode: 0644]
rosapps/net/telnet/src/tncon.h [new file with mode: 0644]
rosapps/net/telnet/src/tnconfig.cpp [new file with mode: 0644]
rosapps/net/telnet/src/tnconfig.h [new file with mode: 0644]
rosapps/net/telnet/src/tnerror.cpp [new file with mode: 0644]
rosapps/net/telnet/src/tnerror.h [new file with mode: 0644]
rosapps/net/telnet/src/tnetwork.cpp [new file with mode: 0644]
rosapps/net/telnet/src/tnetwork.h [new file with mode: 0644]
rosapps/net/telnet/src/tnmain.cpp [new file with mode: 0644]
rosapps/net/telnet/src/tnmain.h [new file with mode: 0644]
rosapps/net/telnet/src/tnmisc.cpp [new file with mode: 0644]
rosapps/net/telnet/src/tnmisc.h [new file with mode: 0644]
rosapps/net/telnet/src/tnmsg.h [new file with mode: 0644]
rosapps/net/telnet/src/tparams.h [new file with mode: 0644]
rosapps/net/telnet/src/tparser.h [new file with mode: 0644]
rosapps/net/telnet/src/tscript.cpp [new file with mode: 0644]
rosapps/net/telnet/src/tscript.h [new file with mode: 0644]
rosapps/net/telnet/src/tscroll.cpp [new file with mode: 0644]
rosapps/net/telnet/src/tscroll.h [new file with mode: 0644]
rosapps/net/telnet/src/ttelhndl.cpp [new file with mode: 0644]
rosapps/net/telnet/src/ttelhndl.h [new file with mode: 0644]
rosapps/net/telnet/telnet.cfg [new file with mode: 0644]
rosapps/net/telnet/telnet.ico [new file with mode: 0644]
rosapps/net/telnet/telnet.ini [new file with mode: 0644]

diff --git a/rosapps/net/telnet/Makefile b/rosapps/net/telnet/Makefile
new file mode 100644 (file)
index 0000000..94f50dd
--- /dev/null
@@ -0,0 +1,139 @@
+#
+# Makefile for Console Telnet
+# Last modified 4/15/2000 by Paul Brannan
+#
+
+SRCDIR=./src
+OBJDIR=src
+RESDIR=resource
+
+SRC=$(wildcard $(SRCDIR)/*.cpp)
+RESOURCES=$(wildcard $(RESDIR)/*.rc)
+OBJ1=$(SRC:.c=.o)
+OBJ=$(OBJ1:.cpp=.o) $(RESOURCES:.rc=.o)
+
+INCLUDES=-I$(RESDIR)
+
+OUT=telnet.exe
+
+# Modify these for your system if necessary
+# Note: DJGPP+RDXNTDJ configuration is untested.
+
+# --CYGWIN--
+#CC=gcc
+#CCC=g++
+#LDFLAGS=-lwsock32 -lmsvcrt
+#CFLAGS=-O2 -Wall -mwindows -mno-cygwin -D__CYGWIN__
+#CCFLAGS=$(CFLAGS)
+#RES=
+#RC=windres
+#RCFLAGS=-O coff
+
+# --MINGW32(+EGCS)--
+CC=gcc
+CCC=g++
+LDFLAGS=-lkernel32 -luser32 -lgdi32 -lshell32 -lwsock32 -lstdc++
+CFLAGS=-O2 -Wall
+CCFLAGS=$(CFLAGS)
+RES=
+RC=windres
+RCFLAGS=
+
+# --DJGPP+RSXNTDJ--
+#CC=gcc -Zwin32 -Zmt -Zcrtdll
+#CCC=$(CC)
+#LDFLAGS=
+#CFLAGS= -g
+#CCFLAGS=$(CFLAGS)
+#RES=rsrc
+#RC=grc
+#RCFLAGS=-r
+
+
+# You should not have to modify anything below this line
+
+all: $(OUT)
+
+.SUFFIXES: .c .cpp .rc
+
+.c.o:
+       $(CC) $(INCLUDES) $(CFLAGS) -c $< -o $@
+
+.cpp.o:
+       $(CCC) $(INCLUDES) $(CCFLAGS) -c $< -o $@
+
+.rc.o:
+       $(RC) -i $< $(RCFLAGS) -o $@
+
+$(OUT): $(OBJ)
+       $(CCC) $(OBJ) $(LDFLAGS) $(LIBS) -o $(OUT)
+       strip $(OUT)
+
+#clean:
+#      del $(OBJDIR)\*.o
+#      del $(OUT)
+clean:
+       "../../../reactos/tools/rdel" "src/*.o"
+
+# DO NOT DELETE
+
+./src/ansiprsr.o: ./src/ansiprsr.h ./src/tnconfig.h ./src/tnerror.h
+./src/ansiprsr.o: ./src/tnmsg.h ./src/tparser.h ./src/tconsole.h
+./src/ansiprsr.o: ./src/keytrans.h ./src/tkeydef.h ./src/tkeymap.h
+./src/ansiprsr.o: ./src/stl_bids.h ./src/tscroll.h ./src/tmouse.h
+./src/ansiprsr.o: ./src/tnclip.h ./src/tnetwork.h ./src/tcharmap.h
+./src/keytrans.o: ./src/keytrans.h ./src/tkeydef.h ./src/tkeymap.h
+./src/keytrans.o: ./src/stl_bids.h ./src/tnerror.h ./src/tnmsg.h
+./src/tcharmap.o: ./src/tcharmap.h ./src/tnconfig.h ./src/tnerror.h
+./src/tcharmap.o: ./src/tnmsg.h
+./src/tconsole.o: ./src/tconsole.h ./src/tnconfig.h ./src/tnerror.h
+./src/tconsole.o: ./src/tnmsg.h
+./src/tkeydef.o: ./src/tkeydef.h
+./src/tkeymap.o: ./src/tkeymap.h ./src/stl_bids.h ./src/tkeydef.h
+./src/tmapldr.o: ./src/tmapldr.h ./src/keytrans.h ./src/tkeydef.h
+./src/tmapldr.o: ./src/tkeymap.h ./src/stl_bids.h ./src/tcharmap.h
+./src/tmapldr.o: ./src/tnerror.h ./src/tnmsg.h ./src/tnconfig.h
+./src/tmouse.o: ./src/tmouse.h ./src/tnclip.h ./src/tnetwork.h
+./src/tmouse.o: ./src/tconsole.h ./src/tnconfig.h ./src/tnerror.h
+./src/tmouse.o: ./src/tnmsg.h
+./src/tnclass.o: ./src/tnclass.h ./src/tnconfig.h ./src/tnerror.h
+./src/tnclass.o: ./src/tnmsg.h ./src/ttelhndl.h ./src/tparser.h
+./src/tnclass.o: ./src/tconsole.h ./src/keytrans.h ./src/tkeydef.h
+./src/tnclass.o: ./src/tkeymap.h ./src/stl_bids.h ./src/tscroll.h
+./src/tnclass.o: ./src/tmouse.h ./src/tnclip.h ./src/tnetwork.h
+./src/tnclass.o: ./src/tcharmap.h ./src/tncon.h ./src/tparams.h
+./src/tnclass.o: ./src/ansiprsr.h ./src/tmapldr.h ./src/tnmisc.h
+./src/tnclip.o: ./src/tnclip.h ./src/tnetwork.h
+./src/tncon.o: ./src/tncon.h ./src/tparams.h ./src/ttelhndl.h ./src/tparser.h
+./src/tncon.o: ./src/tconsole.h ./src/tnconfig.h ./src/tnerror.h
+./src/tncon.o: ./src/tnmsg.h ./src/keytrans.h ./src/tkeydef.h ./src/tkeymap.h
+./src/tncon.o: ./src/stl_bids.h ./src/tscroll.h ./src/tmouse.h ./src/tnclip.h
+./src/tncon.o: ./src/tnetwork.h ./src/tcharmap.h
+./src/tnconfig.o: ./src/tnconfig.h ./src/tnerror.h ./src/tnmsg.h
+./src/tnerror.o: ./src/tnerror.h ./src/tnmsg.h ./src/ttelhndl.h
+./src/tnerror.o: ./src/tparser.h ./src/tconsole.h ./src/tnconfig.h
+./src/tnerror.o: ./src/keytrans.h ./src/tkeydef.h ./src/tkeymap.h
+./src/tnerror.o: ./src/stl_bids.h ./src/tscroll.h ./src/tmouse.h
+./src/tnerror.o: ./src/tnclip.h ./src/tnetwork.h ./src/tcharmap.h
+./src/tnetwork.o: ./src/tnetwork.h
+./src/tnmain.o: ./src/tnmain.h ./src/tncon.h ./src/tparams.h ./src/ttelhndl.h
+./src/tnmain.o: ./src/tparser.h ./src/tconsole.h ./src/tnconfig.h
+./src/tnmain.o: ./src/tnerror.h ./src/tnmsg.h ./src/keytrans.h
+./src/tnmain.o: ./src/tkeydef.h ./src/tkeymap.h ./src/stl_bids.h
+./src/tnmain.o: ./src/tscroll.h ./src/tmouse.h ./src/tnclip.h
+./src/tnmain.o: ./src/tnetwork.h ./src/tcharmap.h ./src/tnclass.h
+./src/tnmain.o: ./src/ansiprsr.h ./src/tmapldr.h ./src/tnmisc.h
+./src/tnmisc.o: ./src/tnmisc.h
+./src/tscript.o: ./src/tscript.h ./src/tnetwork.h
+./src/tscroll.o: ./src/tscroll.h ./src/tconsole.h ./src/tnconfig.h
+./src/tscroll.o: ./src/tnerror.h ./src/tnmsg.h ./src/tmouse.h ./src/tnclip.h
+./src/tscroll.o: ./src/tnetwork.h ./src/tncon.h ./src/tparams.h
+./src/tscroll.o: ./src/ttelhndl.h ./src/tparser.h ./src/keytrans.h
+./src/tscroll.o: ./src/tkeydef.h ./src/tkeymap.h ./src/stl_bids.h
+./src/tscroll.o: ./src/tcharmap.h
+./src/ttelhndl.o: ./src/ttelhndl.h ./src/tparser.h ./src/tconsole.h
+./src/ttelhndl.o: ./src/tnconfig.h ./src/tnerror.h ./src/tnmsg.h
+./src/ttelhndl.o: ./src/keytrans.h ./src/tkeydef.h ./src/tkeymap.h
+./src/ttelhndl.o: ./src/stl_bids.h ./src/tscroll.h ./src/tmouse.h
+./src/ttelhndl.o: ./src/tnclip.h ./src/tnetwork.h ./src/tcharmap.h
+./src/ttelhndl.o: ./src/telnet.h ./src/tparams.h
diff --git a/rosapps/net/telnet/Makefile.mingw b/rosapps/net/telnet/Makefile.mingw
new file mode 100644 (file)
index 0000000..9aab1f5
--- /dev/null
@@ -0,0 +1,142 @@
+#
+# Makefile for Console Telnet
+# Last modified 4/15/2000 by Paul Brannan
+#
+
+SRCDIR=./src
+OBJDIR=src
+RESDIR=resource
+
+SRC=$(wildcard $(SRCDIR)/*.cpp)
+RESOURCES=$(wildcard $(RESDIR)/*.rc)
+OBJ1=$(SRC:.c=.o)
+OBJ=$(OBJ1:.cpp=.o) $(RESOURCES:.rc=.o)
+
+INCLUDES=-I$(RESDIR)
+
+OUT=telnet.exe
+
+# Modify these for your system if necessary
+# Note: DJGPP+RDXNTDJ configuration is untested.
+
+# --CYGWIN--
+#CC=gcc
+#CCC=g++
+#LDFLAGS=-lwsock32 -lmsvcrt
+#CFLAGS=-O2 -Wall -mwindows -mno-cygwin -D__CYGWIN__
+#CCFLAGS=$(CFLAGS)
+#RES=
+#RC=windres
+#RCFLAGS=-O coff
+
+# --MINGW32(+EGCS)--
+CC=gcc
+CCC=g++
+LDFLAGS=-lkernel32 -luser32 -lgdi32 -lshell32 -lwsock32
+CFLAGS=-O2 -Wall
+CCFLAGS=$(CFLAGS)
+RES=
+RC=windres
+RCFLAGS=
+
+# --DJGPP+RSXNTDJ--
+#CC=gcc -Zwin32 -Zmt -Zcrtdll
+#CCC=$(CC)
+#LDFLAGS=
+#CFLAGS= -g
+#CCFLAGS=$(CFLAGS)
+#RES=rsrc
+#RC=grc
+#RCFLAGS=-r
+
+
+# You should not have to modify anything below this line
+
+all: dep $(OUT)
+
+.SUFFIXES: .c .cpp .rc
+
+.c.o:
+       $(CC) $(INCLUDES) $(CFLAGS) -c $< -o $@
+
+.cpp.o:
+       $(CCC) $(INCLUDES) $(CCFLAGS) -c $< -o $@
+
+.rc.o:
+       $(RC) -i $< $(RCFLAGS) -o $@
+
+$(OUT): $(OBJ)
+       $(CCC) $(OBJ) $(LDFLAGS) $(LIBS) -o $(OUT)
+       strip $(OUT)
+
+depend: dep
+
+dep:
+       start /min makedepend -- $(CFLAGS) -- $(INCLUDES) $(SRC)
+
+clean:
+       del $(OBJDIR)\*.o
+       del $(OUT)
+
+# DO NOT DELETE
+
+./src/ansiprsr.o: ./src/ansiprsr.h ./src/tnconfig.h ./src/tnerror.h
+./src/ansiprsr.o: ./src/tnmsg.h ./src/tparser.h ./src/tconsole.h
+./src/ansiprsr.o: ./src/keytrans.h ./src/tkeydef.h ./src/tkeymap.h
+./src/ansiprsr.o: ./src/stl_bids.h ./src/tscroll.h ./src/tmouse.h
+./src/ansiprsr.o: ./src/tnclip.h ./src/tnetwork.h ./src/tcharmap.h
+./src/keytrans.o: ./src/keytrans.h ./src/tkeydef.h ./src/tkeymap.h
+./src/keytrans.o: ./src/stl_bids.h ./src/tnerror.h ./src/tnmsg.h
+./src/tcharmap.o: ./src/tcharmap.h ./src/tnconfig.h ./src/tnerror.h
+./src/tcharmap.o: ./src/tnmsg.h
+./src/tconsole.o: ./src/tconsole.h ./src/tnconfig.h ./src/tnerror.h
+./src/tconsole.o: ./src/tnmsg.h
+./src/tkeydef.o: ./src/tkeydef.h
+./src/tkeymap.o: ./src/tkeymap.h ./src/stl_bids.h ./src/tkeydef.h
+./src/tmapldr.o: ./src/tmapldr.h ./src/keytrans.h ./src/tkeydef.h
+./src/tmapldr.o: ./src/tkeymap.h ./src/stl_bids.h ./src/tcharmap.h
+./src/tmapldr.o: ./src/tnerror.h ./src/tnmsg.h ./src/tnconfig.h
+./src/tmouse.o: ./src/tmouse.h ./src/tnclip.h ./src/tnetwork.h
+./src/tmouse.o: ./src/tconsole.h ./src/tnconfig.h ./src/tnerror.h
+./src/tmouse.o: ./src/tnmsg.h
+./src/tnclass.o: ./src/tnclass.h ./src/tnconfig.h ./src/tnerror.h
+./src/tnclass.o: ./src/tnmsg.h ./src/ttelhndl.h ./src/tparser.h
+./src/tnclass.o: ./src/tconsole.h ./src/keytrans.h ./src/tkeydef.h
+./src/tnclass.o: ./src/tkeymap.h ./src/stl_bids.h ./src/tscroll.h
+./src/tnclass.o: ./src/tmouse.h ./src/tnclip.h ./src/tnetwork.h
+./src/tnclass.o: ./src/tcharmap.h ./src/tncon.h ./src/tparams.h
+./src/tnclass.o: ./src/ansiprsr.h ./src/tmapldr.h ./src/tnmisc.h
+./src/tnclip.o: ./src/tnclip.h ./src/tnetwork.h
+./src/tncon.o: ./src/tncon.h ./src/tparams.h ./src/ttelhndl.h ./src/tparser.h
+./src/tncon.o: ./src/tconsole.h ./src/tnconfig.h ./src/tnerror.h
+./src/tncon.o: ./src/tnmsg.h ./src/keytrans.h ./src/tkeydef.h ./src/tkeymap.h
+./src/tncon.o: ./src/stl_bids.h ./src/tscroll.h ./src/tmouse.h ./src/tnclip.h
+./src/tncon.o: ./src/tnetwork.h ./src/tcharmap.h
+./src/tnconfig.o: ./src/tnconfig.h ./src/tnerror.h ./src/tnmsg.h
+./src/tnerror.o: ./src/tnerror.h ./src/tnmsg.h ./src/ttelhndl.h
+./src/tnerror.o: ./src/tparser.h ./src/tconsole.h ./src/tnconfig.h
+./src/tnerror.o: ./src/keytrans.h ./src/tkeydef.h ./src/tkeymap.h
+./src/tnerror.o: ./src/stl_bids.h ./src/tscroll.h ./src/tmouse.h
+./src/tnerror.o: ./src/tnclip.h ./src/tnetwork.h ./src/tcharmap.h
+./src/tnetwork.o: ./src/tnetwork.h
+./src/tnmain.o: ./src/tnmain.h ./src/tncon.h ./src/tparams.h ./src/ttelhndl.h
+./src/tnmain.o: ./src/tparser.h ./src/tconsole.h ./src/tnconfig.h
+./src/tnmain.o: ./src/tnerror.h ./src/tnmsg.h ./src/keytrans.h
+./src/tnmain.o: ./src/tkeydef.h ./src/tkeymap.h ./src/stl_bids.h
+./src/tnmain.o: ./src/tscroll.h ./src/tmouse.h ./src/tnclip.h
+./src/tnmain.o: ./src/tnetwork.h ./src/tcharmap.h ./src/tnclass.h
+./src/tnmain.o: ./src/ansiprsr.h ./src/tmapldr.h ./src/tnmisc.h
+./src/tnmisc.o: ./src/tnmisc.h
+./src/tscript.o: ./src/tscript.h ./src/tnetwork.h
+./src/tscroll.o: ./src/tscroll.h ./src/tconsole.h ./src/tnconfig.h
+./src/tscroll.o: ./src/tnerror.h ./src/tnmsg.h ./src/tmouse.h ./src/tnclip.h
+./src/tscroll.o: ./src/tnetwork.h ./src/tncon.h ./src/tparams.h
+./src/tscroll.o: ./src/ttelhndl.h ./src/tparser.h ./src/keytrans.h
+./src/tscroll.o: ./src/tkeydef.h ./src/tkeymap.h ./src/stl_bids.h
+./src/tscroll.o: ./src/tcharmap.h
+./src/ttelhndl.o: ./src/ttelhndl.h ./src/tparser.h ./src/tconsole.h
+./src/ttelhndl.o: ./src/tnconfig.h ./src/tnerror.h ./src/tnmsg.h
+./src/ttelhndl.o: ./src/keytrans.h ./src/tkeydef.h ./src/tkeymap.h
+./src/ttelhndl.o: ./src/stl_bids.h ./src/tscroll.h ./src/tmouse.h
+./src/ttelhndl.o: ./src/tnclip.h ./src/tnetwork.h ./src/tcharmap.h
+./src/ttelhndl.o: ./src/telnet.h ./src/tparams.h
diff --git a/rosapps/net/telnet/doc/00readme.avs b/rosapps/net/telnet/doc/00readme.avs
new file mode 100644 (file)
index 0000000..fe0e2d2
--- /dev/null
@@ -0,0 +1,261 @@
+Hi!
+
+Now I come back to telnet source, and make some changes, wich you suggest
+to me:
+
+1.  telnet.rc renamed to telnet.cfg
+2.  I change syntax of 'keys' command (but I did'nt found a tool for edit
+    msg*.bin files - so it's remain unchanged). Syntax are
+
+        keys load keymapname [file]
+        keys display
+        keys switch number
+
+
+I fix some 'political' ;) problem with charmap, now we (citizens of xUSSR)
+have koi8, koi8r and koi8u(RFC on draft) on UNIX, wich are diff's on 6 or
+8 letters; cp866 and many (3 or 4) very near to cp866 on DOS.
+
+So, I rewrite code to able a charmap addition like a keymap done.
+
+And I make more smart command line processing, look at telCommandLine().
+
+And last: my english is not so good :( to rewrite documentation, but there are
+things, wich would be described - look on next page. I think that you will
+translate my english to more understable, ok?
+
+and now is a list of files, wich I touch
+
+
+                            old                         new
+
+ANSIPRSR.CPP        32763  05.10.97  11:09    33237  24.12.97  17:42
+ANSIPRSR.H           3311  04.09.97   0:25     3410  23.12.97  13:18
+KEYTRANS.CPP         9504  28.05.97  22:43    26547  03.02.98  21:33
+KEYTRANS.H           8020  25.01.97  16:06     8090  03.02.98  19:53
+TNCLASS.CPP         13663  17.08.97  23:55    13891  03.02.98  20:09
+TNCLASS.H            1112  01.06.97  14:19     1233  03.02.98  20:09
+TNMAIN.CPP          12668  02.10.97  20:38    16610  03.02.98  21:22
+TNNET.CPP            3445  01.06.97  14:21     3474  23.12.97  13:16
+TNPARSER.CPP        17653  05.10.97  11:09    17715  23.12.97  18:03
+TNPARSER.H           2129  01.06.97  14:22     2188  23.12.97  13:25
+
+KEYS.CFG            erased
+TELNET.CFG          new
+
+TELNET.IDE          65810  26.10.97  16:53    66118  03.02.98  21:34
+
+
+I was start my work with file telc2b4s.zip with size 132619 bytes, and now send
+to you just files, wich I touch.
+
+with best regards
+Andrei V. Smilianets
+
+smile@head.aval.kiev.ua
+22:25 03 Feb 1998
+
+
+\f
+There are all of my changes (from 2.04b), wich have to be described:
+
+1. command line (telnet>) processing
+
+   a 'keys' command
+
+        was
+                keys keymapname [file]
+        new
+                keys load keymapname [file] // mean unchanged
+                keys display                // display a list of loaded keymaps
+                keys switch number          // switch to keymap
+
+   more smart command processing
+
+        command might be writed shortly
+
+          cl[ose]
+          op[en]
+          ke[ys]
+          qu[it]
+
+        subcommands of 'keys'
+
+          l[oad]
+          d[isplay]
+          s[witch]
+
+        synonym of '?' -> h[elp]
+
+2. file 'keys.cfg' renamed to 'telnet.cfg'
+
+3. Added codepage conversion, look [charmap]
+
+4. completely changed conception of telnet.cfg
+
+   Now you can define multiple keymaps, character maps, combine it in your
+   ways.
+
+   file is splitted into following sections:
+
+    [COMMENT]
+     ...
+    [END COMMENT]
+
+        it is for comment a big part of text. can be nested.
+        in text also work:
+
+           ; - first printable character in line, which is completelly
+               ignored.
+           // - like C++ comment
+
+    [GLOBAL]
+    ...
+    [END GLOBAL]
+
+        mean of [global] unchanged
+
+    [KEYMAP name]
+    ...
+    [END KEYMAP]
+        'name' - is a keymap name for reference. in 'name' you can use
+        any char exept spaces, '+', ':' and ']'. '+' and ':' reserved for
+        CONFIG section.
+        body is a sequence of key definition:
+
+           <vk_name> [keymodifier[+keymodifier[+...]]] <keytranslation>
+
+        example:
+           VK_F1 RIGHT_ALT+RIGHT_CTRL this_would_print
+
+        vk_name is an ASCII string equivalent to an entry in [GLOBAL].
+
+        valid keymodifiers are:
+          RIGHT_ALT
+          LEFT_ALT
+          RIGHT_CTRL
+          LEFT_CTRL
+          SHIFT
+          ENHANCED
+
+        Undefined enhanced keys will use the non-enhanced definition.
+
+        keytranslation is the string you want printed for the key.
+        The notation ^[ can be used to denote an escape character.
+        Any ASCII value can be represented by
+
+            \nnn where nnn is a 3 digit decimal ASCII value or
+            \xhh where hh is a 2 digit hexadecimal ASCII value.
+
+        Leading zeros may not be omitted.
+        A value of \000(\x00) will not be transmitted.
+
+        note: In order to have both left and right alt have the same
+        action, you must create a separate def for left and right.
+
+
+    [CHARMAP name]
+    ...
+    [END CHARMAP]
+        'name' - is a charmap name for reference. requirements is the same
+        as for keymap name.
+        body is a sequence of char conversion definition:
+
+           <host_char> <console_char>
+
+        where host_char is a char received from host, and console_char
+        is a char, which would be displayed on console.
+
+        The main purpose of it is a conversion between differents code
+        pages, for example, on former USSR part of world most unix's hosts
+        uses 'koi8' code page, and on W95 machines - 866 code page and
+        (as say I.Ioannou)  Greece has the same problem with 737 and 928
+        code-pages.
+
+
+        Any ASCII value can be represented by
+
+            \nnn where nnn is a 3 digit decimal ASCII value or
+            \xhh where hh is a 2 digit hexadecimal ASCII value.
+
+        Leading zeros may be omitted.
+        A value of \000(\x00) will not be accepted.
+
+        look for example at [charmap koi8-cp866].
+
+    [CONFIG name]
+    ...
+    [END CONFIG]
+        'name' - is a configuration name for reference. requirements is
+        the same as for keymap name.
+
+        you must define one with name 'default', which will be used as
+        default.
+
+        in body of this part you can combine keymaps and set charmap,
+        format is:
+
+           KEYMAP name_list [: <vk_name> [keymodifier[+keymodifier[+...]]] ]
+
+             where
+                  name_list:
+                     keymap_name
+                     keymap_name '+' name_list
+
+                  keymap_name is a name of [KEYMAP]
+
+             You can specify multiple keymaps, for first (mean default)
+             you can not define ': <vk_name> ...' part, but for rests
+             (secondary) you must!
+             The ': <vk_name> ...' part define a key for switch to this
+             keymap.
+
+             Assigning a switching key to first (default) keymap will be
+             ignored, but you can switch to by pressing second time switch
+             key of current keymap.
+
+             If a key not found in switched keymap, a program will be look
+             for it in default keymap. So, you can redefine only needed keys
+             in secondary keymaps.
+
+           CHARMAP name_list
+
+                where
+                      name_list:
+                                charmap_name
+                                charmap_name '+' name_list
+
+                      charmap_name is a name of [CHARMAP]
+
+
+             define wich charmap(s) is to use.
+
+           examples:
+              [config default]
+                 keymap default
+              [end config]
+
+              [config linux]
+                 keymap default + linux
+              [end config]
+
+              [config default_koi8]
+                 keymap default
+                 keymap koi8u + koi8r : VK_/ RIGHT_ALT // russian keyboard
+                 keymap koi8u         : VK_. RIGHT_ALT // ukranian
+
+                 charmap koi8-cp866
+              [end config]
+
+              [config linux_koi8]
+                 keymap default + linux
+                 keymap koi8u + koi8r : VK_/ RIGHT_ALT // russian keyboard
+                 keymap koi8u         : VK_. RIGHT_ALT // ukranian
+
+                 charmap koi8-cp866 + koi8u-cp866
+              [end config]
+
+            so, for switch to russian keyboard just press RIGHT_ALT and '/'.
+            and, for switch back to default press it again.
+
+
diff --git a/rosapps/net/telnet/doc/bugs.txt b/rosapps/net/telnet/doc/bugs.txt
new file mode 100644 (file)
index 0000000..52e1794
--- /dev/null
@@ -0,0 +1,24 @@
+                **********************************************
+                *** Console Telnet 2.1 beta 2.  Known Bugs ***
+                **********************************************
+
+
+Wrap_Line = 0   Doesn't work very well. It works with elvis or talk on linux,
+                but messes up bash at last line.
+
+Enable_Mouse=1  Causes the display to slow in fullscreen mode, since the
+                mouse has to be erased and then drawn again for every
+                screen write.
+
+Term_Width or Term_Height != -1 or Wide_Enable=1
+                Specifying any of these can cause display problems if
+                the font size is not set to auto.
+
+Resizing the current window while running telnet can cause problems, especially
+if doing so makes the buffer smaller.  This should be more of a problem on
+NT/W2K than on 95/98.  Part of the problem is that the telnet NAWS option
+negotiation isn't done properly.  On a related note, turning on scrollbars can
+decrease performance.
+
+There are many other bugs, most of which are documented in the code.  Just
+grep the source for "FIX ME".
diff --git a/rosapps/net/telnet/doc/changes.txt b/rosapps/net/telnet/doc/changes.txt
new file mode 100644 (file)
index 0000000..4e03d47
--- /dev/null
@@ -0,0 +1,239 @@
+                **********************************************
+                *** Console Telnet version 2.1 Change log  ***
+                **********************************************
+
+Version 2.1b2 -- October 16, 2000
+  Redirection fix (Mark Miesfield)
+  Allow "o" to open a connecton on the command line
+  Fixed problem with special keys (ALt-[, Alt-], Alt-\, etc.)
+  Added MTE Support (Ziglio Frediano)
+  Speed improvements in ttelhndl.cpp -- may be buggy?
+  Wrap_line option is now modifiable via telnet command line
+  Lock_linewrap option added
+  Cleaned up console code
+  Fixed some color issues with nonstandard consoles
+  Tab setting/resetting
+  Fixed "telnet.exe" installer problem
+  Fixed miscellaneous parsing bugs
+  Fixed vt100-compliance
+  Added NAWS support, but it doesn't work (RFC 1073)
+  Added X Display Location support (RFC 1096)
+
+Version 2.1b1 -- April 5, 2000
+-Bugfixes
+  Console code writes to bottom of buffer (W2K scrollback buffer now works)
+  Updated Winsock error messages (Craig Nellist)
+  Sleeping while thread paused, to give up CPU time (Craig Nellist)
+  Ctrl_Break_as_C now works properly
+  Restore original screen colors; use initial screen colors as default
+
+-New features
+  Cursor size sequences (Jose Cesar Otero Ridriguez)
+  Network piping
+  Line mode support added
+  Support for telnet:// URLs
+  Command-line history (Craig Nellist)
+  Connection Aliases
+
+-Translator updates
+  New code structure
+  Unified character map class
+  More configurable "special" keys:
+    tn_escape, tn_scrollback, tn_dial, tn_paste, tn_null, tn_cr, tn_crlf
+  Transmission of NUL character possible
+  Czech keyboard definition (Jakub Sterba)
+
+-New INI options
+  Window_Width, Window_Height
+  Scriptname (not functional), Script_Enable (not functional)
+  Netpipe (functional), Iopipe (not functional)
+
+Version 2.0 -- July 5, 1999
+-Bugfixes
+  Save/restore console title, character mapping fix (Pedro Gutierrez)
+  Telnet prompt fix, suspend telnet, string-based port (Craig Davidson)
+  Mutt/Lynx colors/underline fix, repeat character fix
+  Color display problem fixed (I.Ioannou)
+  Newline properly handled, added APP4_KEY, better key translation
+  Problem with icons not displaying properly fixed
+  Small bug with telnet crashing at exit (Sam Robertson, Daniel Straub)
+  Bug getting name of executable (Thomas Briggs)
+
+-Updates
+  Better key translation
+  Spanish keyboard definition (Cesar Otero)
+
+-New ini options
+  Set_Title (Adi Seiker)
+  Scroll_Enable/Scroll_Size
+  CtrlBreak_as_CtrlC (Bryan Montgomery)
+  Clear_on_Tabset removed
+  
+Version 2.0b7.1 -- Dec. 5, 1998
+-Minor changes
+  Fixed problems with Scrollback and Clipboard
+  Minor updates to terminal emulation
+  Keyboard init improvements (Vassili Bourdo)
+  Repeat sequence support, German key config (Titus von Boxberg)
+
+Version 2.0b7 -- Oct. 21, 1988
+-To do still:
+  ZModem support
+  Update key translator/character maps
+  Finish scrollback
+
+-Changes
+  Options added: Term_Width, Term_Height, Wide_Enable, Buffer_Size, Dial_key,
+        Keyboard_Paste, Status_bg, Status_fg, Input_Redir, Output_Redir
+
+  Application keypad mode support
+  Numlock/scroll lock support in KEYS.CFG
+  Del/. key now works properly
+  Ctrl-break bugfixes (Thomas Briggs)
+
+  Added suspend and fast quit to the command line (Thomas Briggs)
+  Error message for unable to load ini file (Thomas Briggs)
+  Fixed TELNET_INI environment variable (BK Oxley)
+
+  Support for changing screen size
+  Support for switching to 132-column mode via ANSI sequences
+
+  Fixed minor memory leaks
+  Mouse speedups/bugfixes, scrolling speedups/bugfixes
+  Miscellaneous ANSI parser fixes
+
+  Added support for changing the icon in the corner of the window
+  Fixed bug with mIRC
+  Fixed "try again" error message
+  Input and output redirection now separate (TELNET_REDIR still supported)
+  Modified "set" command to operate on groups
+  Character mapping now works again
+
+Version 2.0b6 28 Jul 1998
+-To Do still:
+  ZModem support
+  Finish mouse support
+  Fix character maps
+
+-Changes:
+  ANSI Parser should be almost complete
+  Reorganized source
+  Display speedups
+  Preliminary mouse support
+  Enhanced scrollback support
+  Miscellaneous bug fixes
+
+Version 2.0b5 05 Jun 1998
+-Version 2b5 released from I.Ioannou <roryt@hol.gr>
+-To Do Still:
+  Too many to mention :-)
+-To Do, Maybe:
+  Mouse cut/paste support.
+  Support secure telnet options.
+  Real blinking attributes.
+  Zmodem & Kermit DL Protocols.
+  Any ideas acceptable :-)
+
+
+May 1998
+-Changes
+   Paul Brannan <pbranna@clemson.edu> add telnet.ini code
+   improve telnet's speed, add some VT emulation, port telnet to
+   MSVC, rewrote the command line options processing with GNU getopt,
+   fix many bugs, and more.  Good work Paul :-)
+   I.Ioannou <roryt@hol.gr> . A few bugs fixes, and a icon.
+   Also I convert tnmsg files to use a resource compiler.
+
+December 1997
+-Changes
+    Andrey V. Smilianets (smile@head.aval.kiev.ua)
+    rewrote the keys translator to support many different
+    keymaps, charmaps and configurations.
+    Also add editing support to telnet> prompt.
+
+
+Version 2.0b4 10/6/97
+-Updated by Brad Johnson who can be contacted at
+  <jbj@nounname.com>  http://nounname.com
+-Changes
+  Added command line history at the telnet> prompt.
+  Added ability to "unmap" a key by setting it equal to \000 in the key.cfg.
+  Added log-file option '-dFILENAME'.
+  Added print screen/line commands by I.Ioannou <roryt@hol.gr>.
+  Added Support for running in an emacs buffer <mauch@unidui.uni-duisburg.de>.
+  Added better support for international character sets
+     <mauch@unidui.uni-duisburg.de>.
+-To Do Still:
+  Support for local echo.
+  Scrollback buffer.
+  Fix Scrolling bug.
+-To Do, Maybe:
+  Change the telnet options to initiate the negotiation.
+  Mouse cut/paste support.
+  Support secure telnet options.
+  Real blinking attributes.
+  Zmodem & Kermit DL Protocols.
+
+Version 2.0b3  12/25/96:
+-Updated by Brad Johnson who can be contacted at
+  <jbj@nounname.com>  http://nounname.com
+-Changes
+  Screen colors and buffer settings are now preserved on exit.
+  Fixed WindowSize height/width 255 exception :-).
+  Found out that the paste problem is a bug in Win 95 (not my problem)!
+  Fixed screen buffer problems under NT when the window
+    was smaller than the buffer.
+  Added custom key maps by I.Ioannou <roryt@hol.gr>.
+-To Do Still:
+  Fix advance to next line error when writing past column
+  Extend NAWS window negotiation to include buffer size changes.
+  Change the telnet options to initiate the negotiation.
+  Add print screen/line commands.
+-To Do, Maybe:
+  Support for running in an emacs buffer.
+  Mouse cut/paste support.
+  Support secure telnet options.
+  Real blinking attributes.
+  Zmodem & Kermit DL Protocols.
+
+Version 2.0b2  09/29/96:
+-Updated by Brad Johnson who can be contacted at
+  <jbj@nounname.com>  http://nounname.com
+-Changes
+  Added code to move cursor to end of screen and reset attributes on close
+  Fixed potential IAC parsing problem
+  Fixed ClearScreen Last line problem
+  Fixed parse problem that prevented line clears on unix history
+  Changed scroll code to scroll the entire buffer
+  Removed destructive backspace. May cause problems with terminals that want
+    destructive backspaces.
+  Added binary telnet option to use 8bit.
+-To Do Next
+  Paste still doesn't work!
+
+Version 2.0b1  09/22/96:
+-Updated by Brad Johnson who can be contacted at
+  <jbj@nounname.com>  http://nounname.com
+-Changes
+  Added Color ANSI support. It works!
+  Added option for user specified port addresses on the command line.
+  Added ANSI keyboard mapping support for cursor keys.
+  Added destructive Backspace.
+  Added escape key 'ALT-]'.
+  Added TermType and WindowSize telnet options.
+  Added/Fixed various other ANSI codes.
+  Now (I hope) all ANSI codes handled correctly!
+  Fixed cursor left/right/save/restore commands.
+  Fixed clear line and clear screen command.
+  Expanded and altered network buffer to prevent some lockups :-).
+  Added Unix style telnet prompt "telnet>" with options.
+-To Do Next
+  Should parse for IAC separate from ANSI.
+
+Version 1.0a:
+- This release fixes a bug which caused it to hang when connecting to
+  UNIX boxes. The program simply ignored Telnet DO instead of replying
+  with WON'T as required by RFC 854.
+
+Version 1.0:
+- First release
diff --git a/rosapps/net/telnet/doc/license.txt b/rosapps/net/telnet/doc/license.txt
new file mode 100644 (file)
index 0000000..3358a7b
--- /dev/null
@@ -0,0 +1,340 @@
+                   GNU GENERAL PUBLIC LICENSE
+                      Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+                          675 Mass Ave, Cambridge, MA 02139, USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                           Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+\f
+                   GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+\f
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+\f
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+\f
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+                           NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+                    END OF TERMS AND CONDITIONS
+\f
+       Appendix: How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) 19yy  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) 19yy name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.
+
diff --git a/rosapps/net/telnet/doc/options.txt b/rosapps/net/telnet/doc/options.txt
new file mode 100644 (file)
index 0000000..fefd154
--- /dev/null
@@ -0,0 +1,187 @@
+This file describes all the environment variables and options that are
+available in TELNET.INI.  If you are having problems with a terminal setting,
+this is the file you want to read first.  If this file does not help you,
+please send a bug report to Paul Brannan <pbranna@clemson.edu>.
+
+Environment variables
+---------------------
+
+Before there was a telnet.ini file, all the options were controlled
+through environment variables.  These have been left in for compatibility
+with previous versions, and for specifying locations of files.  They
+override any values in telnet.ini.
+
+TELNET_CFG      Specifies the location of the keys.cfg file
+TELNET_REDIR    Specifies whether file redirection needs to be supported
+INPUT_REDIR     Specicies only to redirect input
+OUTPUT_REDIR    Specifies only to redirect output
+TELNET_INI      Specifies the location of the telnet.ini file
+
+Configuration options
+---------------------
+
+These are the options that you can specify in telnet.ini.  This file is in
+the same format as any normal Windows ini file.  You can also change some
+of these options using the SET command at the telnet> prompt.
+
+[Terminal] section
+
+Dumpfile
+Specifies the filename of a file to dump output to.  (Default = "")
+
+Term
+The name of the terminal type to send to the server.  You
+can use this if Telnet is sending "ANSI" but you have a
+vt100 terminal.  If you use this options, please read about
+some of the other options below.  (Default = ansi)
+
+EightBit_Ansi
+Some machines use the ASCII characters 128 to 155 for ANSI
+sequences.  These are usually the newer VAX systems.  Turning
+this option on may cause problems with certain foreign
+(non-American) character sets.  (Default = FALSE)
+
+VT100_Mode
+This option turns on VT100 mode.  There are a few minor
+differences between ANSI terminals and DEC VT100 terminals.
+I recommend trying TERM=vt220 or TERM=vt102 before trying
+this option, but if you must have true VT100 emulation,
+this is the only way to get it.  (Default = FALSE)
+
+Destructive_Backspace
+This will probably cause problems with most programs, but if you need the
+backspace to erase the previous character (as with some BBSes), use this
+option.  (Default = FALSE)
+
+Speaker_Beep
+If you set this to true you will hear beeps through the PC speaker; setting
+it to false will play the default system beep sound through your sound
+card.  (Default = TRUE)
+
+Beep
+Setting this to false turns off all beeps; setting this to true turns on
+all beeps.  (Default = TRUE)
+
+Preserve_Colors
+This turns on color preservation for systems that require it (like SCO).
+(Default = FALSE)
+
+Wrap_line
+This turns on/off line wrap.  (Default = TRUE)
+
+Lock_linewrap
+Turning on this option disables the ability of the remote end to control
+line wrap, and "locks" it into whatever it is set to in the ini file.
+(Default = FALSE)
+
+Fast_write
+This turns on/off fast screen write.  Turning it off allows you to see
+control characters if your application requires it.  (Default = TRUE)
+
+Term_width
+Term_height
+These options specify the size of the terminal.  You can specify non-standard
+sizes if you are running telnet in a window.  You may want to specify
+a font size if you use these (using "Auto" can cause display problems).
+Specifying -1 means use the settings for the parent console.
+(Default = -1, -1)
+
+Wide_enable
+This is to allow the ANSI parser to change the screen size when sent certain
+escape sequences.  This is for vt100 compatibility.  (Default = FALSE)
+
+Buffer_size
+This is the size of the ANSI buffer used for parsing sequences.  Increasing
+this value speeds up the parser, and decreasing it allows the mouse to
+respond faster.  (Default = 2048)
+
+Input_redir
+Output_redir
+These are for redirecting input and output.  (Default = 0, 0)
+Any value greater than 0 turns redir on.  Turn Output_redir on to bypass
+the Console Telnet screen writing and positioning functions and simply
+pass the data stream as received from the host straight through.
+
+Strip_redir
+If enabled, this option will attempt to strip the stream before passing it on
+through redirected output.  This will have no effect on non-redirected output.
+(Default=FALSE)
+
+[Colors] section
+
+Setting the following to -1 disables them:
+Blink_bg                Background color to use for blink (default = -1)
+Blink_fg                Foreground color to use for blink (default = -1)
+Underline_bg            Background color to use for underline (default = -1)
+Underline_fg            Foreground color to use for underline (default = -1)
+UlBlink_bg              Background color to use for blink+uline (default = -1)
+UlBlink_fg              Foreground color to use for blink+uline (default = -1)
+
+Setting the following to -1 uses colors detected at startup:
+Normal_bg               Normal text background color (default = -1)
+Normal_fg               Normal text foreground color (default = -1)
+
+Please do not set these values to -1:
+Scroll_bg               Background color for scrollback mode (default = 0)
+Scroll_fg               Foreground color for scrollback mode (default = 7)
+Status_bg               Bg color of status line in scrollback (default = 1)
+Status_fg               Fg color of status line in scrollback (default = 15)
+
+Here's a list of colors:
+0 - black, 1 - blue, 2 - green, 3 - cyan, 4 - red, 5 - magenta, 6 - brown
+7 - lt. grey (dk. white), 8 - dk. grey, 9 - bright blue, 10 - bright green,
+11 - bright cyan, 12 - bright red, 13 - bright magenta, 14 - yellow
+15 - bright white
+
+[Mouse] section
+
+Enable_Mouse
+Turns on mouse support.  (Default = TRUE)
+
+[Printer] section
+
+Printer_Name
+The DOS name for the printer.  (Default = LPT1)
+
+[Keyboard] section
+Many of these options are also available from telnet.cfg.
+
+Escape_key
+The key to break out of a telnet session.  (Default = ])
+
+Scrollback_key
+The key for switching to scrollback mode.  (Default = [)
+
+Dial_key
+You can start a new telnet session with this key.  (Default = \)
+
+Alt_erase
+If you set this to true, it will swap backspace and delete.
+(Default = FALSE)
+
+Keyboard_paste
+This option allows pasting to the screen via shift-insert.  (Default = FALSE)
+
+Keyfile
+Selects an alternate telnet.cfg file.  (Default = TELNET.CFG)
+
+Default_Config
+Selects a different keyboard definition.  All of these are defined in
+telnet.cfg.
+
+[Scrollback] section
+
+Scroll_Mode
+Selects the default mode for scrollback.  Valid selections are:
+        HEX             Hex dump
+        DUMP            Dump, control characters are shown as "."
+        DUMPB           Binary dump
+        TEXT            Text mode
+Note: you can press TAB in scrollback mode to cycle through these.
+(Default = DUMP)
+
+Command-line Options
+--------------------
+
+-d<filename>    Specifies the name of the dumpfile.
+-h             Gives a help screen.
diff --git a/rosapps/net/telnet/doc/readme.txt b/rosapps/net/telnet/doc/readme.txt
new file mode 100644 (file)
index 0000000..abebe34
--- /dev/null
@@ -0,0 +1,280 @@
+              **************************************************
+              ** Console Telnet v2.1b2 README.TXT 16 Oct 2000 **
+              **************************************************
+
+                               RELEASE NOTES:
+                               --------------
+
+This release of TELNET is a beta one. This means that it is working as far
+as it is tested, and has a few bugs. Hopefully this will be a stable
+version.  Please send comments and bug reports to me at
+pbranna@clemson.edu, or to the mailing list (see below).  See file
+CHANGES.TXT for a detailed log of changes.  See file BUGS.TXT for known
+bugs.
+
+                                DESCRIPTION:
+                                ------------
+
+This is a telnet client with full color ANSI support for Windows NT/95
+console. You can use this program from the Win95 command line (MsDos) and
+run it in full screen text mode. You may also redirect the telnet session
+to STDIN and STDOUT for use with other programs.  Telnet will communicate
+the number of lines and rows to the host, and can operate in any console
+mode.  Most of it's options are customizable.
+
+
+                         COPYRIGHT/LICENSE/WARRANTY
+                         --------------------------
+
+Telnet Win32, Copyright (C) 1996-1997, Brad Johnson <jbj@nounname.com>
+Copyright (C) 1998 I.Ioannou, Copyright (C) 1999-2000 Paul Brannan.  Telnet
+is a free project released under the GNU public license.  This program comes
+with ABSOLUTELY NO WARRANTY.  This is free software, and you are welcome
+to redistribute it under the licence contitions.  See LICENSE.TXT for
+details.
+
+                                REQUIREMENTS:
+                                -------------
+
+This program requires a Microsoft Win32 enviroment (Windows 95/98/NT) with
+Winsock TCP/IP.  16 bit Win3.x or Win32s are not supported.
+
+                                  FEATURES:
+                                  ---------
+
+Full ANSI colors and (almost) complete ANSI emulation.
+User configurable options via telnet.ini.
+User configurable key bindings with alternative keyboards.
+Icoming character translations.
+Redirection of telnet session.
+Telnet output can be dumped to a file.
+Local printer support.
+Basic scrollback support.
+Basic VT emulation.
+Mouse support.
+Clipboard (cut-and-paste) support.
+Support for multiple screen sizes.
+
+                              WHERE TO GET IT:
+                              ----------------
+
+Since version 2.0, Console Telnet's new home page is
+http://www.musc.edu/~brannanp/telnet/.  You can get the latest version from
+ftp://argeas.cs-net.gr/Telnet-Win32 or from the web page.  Telnet is
+available as full project (sources included) or as binaries only.  If you
+would like to help to the development check the /devel directory on the ftp
+site for a recent alpha version.
+
+                                MAILING LIST:
+                                -------------
+
+Telnet has it's own mailing list for announcements, bug reports, support,
+suggestions etc. To subscribe send e-mail to majordomo@argeas.cs-net.gr
+with empty Subject, and the word subscribe in the body. List's address is
+telnet-win32@argeas.cs-net.gr You can find the old archives at
+http://www.cs-net.gr/lists
+
+If you are only interested in announcements, follow the above procedures to
+subscribe to telnet-win32-announce.  The development list is
+telnet-win32-devel.
+
+                                HOW TO HELP:
+                                ------------
+
+Telnet is a free project made from volunteers. If you know C/C++ and would
+like to help in the development you are welcome :-)  Just contact
+pbranna@clemson.edu, and/or subscribe to the mailing list.  Check
+ftp://argeas.cs-net.gr/Telnet-Win32/devel for a recent alpha version.
+
+
+                                INSTALLATION
+                                ------------
+
+Just copy telnet.exe, telnet.ico, telnet.ini and keys.cfg to a directory.
+I prefer a directory included in the PATH (such as C:\WINDOWS, but this will
+overwrite the telnet that comes with Windows -- which is not necessarily a
+bad thing). If you are upgrading from a previous version please look below
+(Key file definitions) : the keys.cfg file has changed a bit. Also look at
+the Configuration section below, TELNET now has a ini file.
+
+                                   USAGE:
+                                   -------
+
+  TELNET
+    Begins telnet and enters telnet> command line.
+
+  TELNET [params][host [port]]
+    Connects to port on host. Port defaults to 23 for TELNET.
+
+    params    -d FILENAME.EXT    Dumps all incoming data to FILENAME.EXT
+                                 Note lowercase 'd'.
+              --variable=value   Overrides ini variable to be set to value.
+
+    host                         Host name or IP to connect to
+    port                         Service port to open connection on
+                                 (default is telnet port 23).
+
+  TELNET -?
+    Gives usage information.
+
+Pressing the escape key (default ALT-]) will break out of a telnet session and
+return you to the telnet> prompt. Pressing return will resume your session.
+All the options are available from the telnet> prompt. Type ? to get help.
+
+Pressing the scrollback key (default ALT-[) will give you a basic scrollback
+view. Pressing ESC will resume your session.
+
+                                   BUGS:
+                                   -----
+
+There are :-). Hopefully this version is more stable than the previous. See
+BUGS.TXT, and grep for FIX ME's in the sources. Any help ?
+
+                                   NOTES:
+                                   ------
+
+If the environment variable LANG has a valid value (e.g. LANG=de for German
+characters) and the file LOCALE.DLL is installed somewhere along the PATH
+TELNET will not ignore local characters.
+
+If you have problems with paste under Win 95 try unchecking the fast paste
+option in the MsDos properties. The paste function works correctly under NT.
+This is a Microsoft bug :-)
+
+                                CONFIGURATION
+                                -------------
+
+The configuration is made through telnet.ini and keys.cfg. These files (at
+least telnet.ini) must be in the same directory which telnet.exe is.  The
+basic options are loaded from the file telnet.ini. If you are having problems
+with a terminal setting, check the file OPTIONS.TXT for configuration
+information.
+
+
+Key file definitions (telnet.cfg)
+-------------------------------
+
+Use the key file (telnet.cfg) to define the characters that telnet is sending
+to the host.  From version 2b5 you can configure the output keys (KEYMAP
+sections), the input character translations (CHARMAP sections) and you can
+combine all to as many configurations as you like (CONFIG sections). You
+can also have alternative keymaps in a configuration, and keys to switch
+between them.  See the comments in keys.cfg for details.
+
+NOTE: if you are upgrading from a previous version you must put your old keys
+in the KEYMAP sections.
+Please send any national specific keymaps / charmaps / configurations to be
+included to the next version.
+
+
+                              HOW TO COMPILE IT
+                             -------------------
+
+Telnet compiles with a variety of compilers.  You will need at least
+Borland 4.x or newer compiler, or MSVC 2.0 or newer, or download a version
+of gcc for Win32 (see http://www.musc.edu/~brannanp/telnet/gccwin32.html).
+Copy the files from the directories BORLAND or MSVC to the main directory,
+change them to fit to your system, and recompile.  The project comes with
+IDE files and makefiles.
+
+Follow the instructions for your compiler to compile telnet.  A Makefile
+for use with mingw32 or other gcc variants has been included, so if you have
+gcc, you can just type "make" at the command line.
+
+                               SPECIAL THANKS:
+                               ---------------
+
+Many people have worked for this project. Please forgive me (and let me
+know!) if I have forgotten anyone. We all thank them :-)
+
+Igor Milavec <igor.milavec@uni-lj.si>
+        Original Author of version 1.1
+        Igor wrote the basic telnet program and released it to public.
+
+Brad Johnson <jbj@nounname.com>  http://nounname.com
+        Author of versions 2.0b to 2b4. Brad has wrote plenty of code for
+        telnet like ansi colors, emulation, scrollback option, and many
+        others.
+
+Titus_Boxberg@public.uni-hamburg.de
+        Ansi emulation improvements
+        German keyboard configuration
+
+I.Ioannou roryt@hol.gr
+        KeyTranslator class (version 2b3)
+        Maintainer (since version 2b5)
+
+Andrei V. Smilianets <smile@head.aval.kiev.ua> (version 2b5)
+        KeyTranslator class (version 2b5)
+        Prompt improvments
+
+Paul Brannan <pbranna@clemson.edu>
+        Telnet.ini author, MSVC port, speed improvements, VT support,
+        and many others.
+        Maintainer (since version 2b6)
+
+Leo Leibovici <leo.leibovici@nouveau.co.uk>
+        Fixed some crashes in the ANSI parser
+        Wrote UK keymap
+
+Dmitry Lapenkov <dl@bis.msk.su>
+        Wrote AT386 keymaps
+        Improved telnet icon
+
+Thomas Briggs <tbriggs@qmetric.com>
+        Fixed problem with Ctrl-Break
+        Added suspend and fast quit options to the command line
+        Error messages for unable to load ini file
+        Fixed bug w/ getting name of executable
+
+BK Oxley
+        Fixed TELNET_INI environment variable
+
+Sam Robertson
+        Fixed compilation problems with MSVC6
+        Bugfix with telnet crashing at exit
+
+Vassili Bourdo <vassili_bourdo@softhome.net>
+        Keyboard initialization improvements
+
+Craig Davidson <crn@ozemail.com.au>
+        Bugfixes for telnet prompt
+        Added suspend telnet option
+        Set port number using name rather than number
+
+Pedro Gutierrez <paag@coppi.tid.es>
+        Save/restore console title
+        Bugfix w/ character mapping
+
+Daniel Straub <Daniel.Straub@nbgm.siemens.de>
+        Bugfix with telnet crashing at exit
+
+Jose Cesar Otero Rodriguez <jcotero@las.es>
+        Spanish Keyboard definition
+        Cursor size sequences
+
+Bryan Montgomery <monty@english.net>
+        Added CtrlBreak_as_CtrlC option
+        Added Scroll_Enable option
+
+Adi Seiker
+        Added Set_Title ini file option
+
+Craig Nellist
+        Updated Winsock error messages
+        Sleeping while thread paused, to give up CPU time
+        Command-line history
+
+Jakub Sterba
+        Czech keyboard definition
+
+Ziglio Frediano
+        MTE (Meridian Terminal) Support
+
+Mark Miesfield
+       Fixed redirection
+       Wrote documentation for redirection
+
+---
+
+Paul Brannan <pbranna@clemson.edu>
diff --git a/rosapps/net/telnet/doc/ssh.txt b/rosapps/net/telnet/doc/ssh.txt
new file mode 100644 (file)
index 0000000..077d79b
--- /dev/null
@@ -0,0 +1,22 @@
+It should be possible to add ssh support to console telnet, as console telnet has a very modular design when it comes to the networking code.  There is already support for pipes, and if there exists an ssh client for Win32 that will output to stdout, then you're in business.  I'm yet to find such a client, but if one existed, an SSH session could be started like so:
+
+C:\> telnet
+Copyright message, license.txt, stuff, etc.
+telnet> set io_netpipe "C:\BIN\SSH.EXE -l username host"
+telnet> open blah
+login:
+password:
+
+Unfortunately, all the ssh clients I've found don't work this way.  You can output CMD.EXE to telnet this way, though, and get a very pretty ansi interpreter.  If you want to try to get OpenSSH working, here's step-by-step instructions to get you started (please read them all the way though):
+
+1) Get Perl from http://www.activestate.com/ActivePerl/download.htm
+2) Get Openssl from http://www.openssl.org/source/
+   - Follow directions in INSTALL.W32
+   - Copy the .LIB files from OUT32DLL to your LIB directory (C:\DevStudio\VC\LIB)
+   - Copy the .DLL files from OUT32DLLto your system directory (C:\Winnt\System32 or C:\Windows\System)
+   - Copy the .H files from INC32\OPENSSL to your include\ssl (C:\DevStudio\VC\include\ssl)
+   - Copy these same files to include\openssl (C:\DevStudio\VC\include\openssl)
+3) Get Openssh from http://www.openssh.com
+4) Modify Openssh so it will compile, and get rid of all the termios stuff
+
+Obviously this is a lot of work.  If you need a good ssh client, try PuTTY from http://www.chiark.greenend.org.uk/~sgtatham/putty/.  It may be possible to integrate PuTTY and Telnet, and that would certainly be easier than the above option.  PuTTY is licensed under the MIT license, which seems to be compatible with the GPL.  The primary advantage of integrating the two projects is that PuTTY would gain the key mappings that telnet has, and telnet would gain encryption.
\ No newline at end of file
diff --git a/rosapps/net/telnet/resource/tnmsg.h b/rosapps/net/telnet/resource/tnmsg.h
new file mode 100644 (file)
index 0000000..b46f8cb
--- /dev/null
@@ -0,0 +1,108 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by Tnmsg.rc
+//
+#define MSG_COPYRIGHT                   0x01
+#define MSG_COPYRIGHT_1                 0x02
+#define MSG_USAGE                       0x03
+#define MSG_USAGE_1                     0x04
+#define MSG_HELP                        0x05
+#define MSG_HELP_1                      0x06
+#define MSG_INVCMD                      0x07
+#define MSG_ERROR                       0x08
+#define MSG_INFO                        0x09
+#define MSG_WARNING                     0x0a
+#define MSG_TRYING                      0x0b
+#define MSG_CONNECTED                   0x0c
+#define MSG_TERMBYREM                   0x0d
+#define MSG_KEYMAP                      0x0e
+#define MSG_ERRKEYMAP                   0x0f
+#define MSG_DUMPFILE                    0x10
+#define MSG_CONFIG                      0x11
+#define MSG_NOINI                       0x12
+#define MSG_BADVAL                      0x13
+#define MSG_NOSPAWN                     0x14
+#define MSG_RESOLVING                                  0x15
+#define MSG_NOSERVICE                                  0x16
+#define MSG_SIZEALIAS                                  0x17
+#define MSG_ERRPIPE                                            0x18
+#define MSG_BADUSAGE                                   0x19
+#define MSG_ALREADYCONNECTED                   0x1a
+
+#define MSG_KEYNOVAL                    1001
+#define MSG_KEYBADVAL                   1002
+#define MSG_KEYBADSTRUCT                1003
+#define MSG_KEYBADCHARS                 1004
+#define MSG_KEYUNEXPLINE                1005
+#define MSG_KEYUNEXPEOF                 1006
+#define MSG_KEYUNEXPTOK                 1007
+#define MSG_KEYUNEXPTOKIN               1008
+#define MSG_KEYUNEXP                    1009
+#define MSG_KEYNOGLOBAL                 1010
+#define MSG_KEYNOCONFIG                 1011
+#define MSG_KEYUSECONFIG                1012
+#define MSG_KEYNOSWKEY                  1013
+#define MSG_KEYCANNOTDEF                1014
+#define MSG_KEYDUPSWKEY                 1015
+#define MSG_KEYUNKNOWNMAP               1016
+#define MSG_KEYNOCHARMAPS               1017
+#define MSG_KEYNOKEYMAPS                1018
+#define MSG_KEYNUMMAPS                  1019
+#define MSG_KEYBADMAP                                  1020
+#define MSG_KEYMAPSWITCHED                             1021
+
+#define MSG_WSAEINTR                    0x2714
+#define MSG_WSAEBADF                    0x2719
+#define MSG_WSAEACCESS                  0x271D
+#define MSG_WSAEDEFAULT                 0x271E
+#define MSG_WSAEINVAL                   0x2726
+#define MSG_WSAEMFILE                   0x2728
+#define MSG_WSAEWOULDBLOCK              0x2733
+#define MSG_WSAEINPROGRESS              0x2734
+#define MSG_WSAEALREADY                 0x2735
+#define MSG_WSAENOTSOCK                 0x2736
+#define MSG_WSAEDESTADDRREQ             0x2737
+#define MSG_WSAEMSGSIZE                 0x2738
+#define MSG_WSAEPROTOTYPE               0x2739
+#define MSG_WSAENOPROTOOPT              0x273A
+#define MSG_WSAEPROTONOTSUPPORT         0x273B
+#define MSG_WSAESOCKNOTSUPPORT          0x273C
+#define MSG_WSAEOPNOTSUPP               0x273D
+#define MSG_WSAEPFNOTSUPPORT            0x273E
+#define MSG_WSAEAFNOTSUPPORT            0x273F
+#define MSG_WSAEADDRINUSE               0x2740
+#define MSG_WSAEADDRNOTAVAIL            0x2741
+#define MSG_WSAENETDOWN                 0x2742
+#define MSG_WSAENETUNREACH              0x2743
+#define MSG_WSAENETRESET                0x2744
+#define MSG_WSAECONNABORTED             0x2745
+#define MSG_WSAECONNRESET               0x2746
+#define MSG_WSAENOBUFS                  0x2747
+#define MSG_WSAEISCONN                  0x2748
+#define MSG_WSAENOTCONN                 0x2749
+#define MSG_WSAESHUTDOWN                0x274A
+#define MSG_WSAETOOMANYREFS             0x274B
+#define MSG_WSAETIMEDOUT                0x274C
+#define MSG_WSAECONNREFUSED             0x274D
+#define MSG_WSAELOOP                    0x274E
+#define MSG_WSAENAMETOOLONG             0x274F
+#define MSG_WSAEHOSTDOWN                0x2750
+#define MSG_WSAEHOSTUNREACH             0x2751
+#define MSG_WSAESYSNOTREADY             0x276B
+#define MSG_WSAVERNOTSUPPORTED          0x276C
+#define MSG_WSANOTINITIALISED           0x276D
+#define MSG_WSAHOST_NOT_FOUND           0x2AF9
+#define MSG_WSATRY_AGAIN                0x2AFA
+#define MSG_WSANO_RECOVERY              0x2AFB
+#define MSG_WSANO_DATA                  0x2AFC
+
+// Next default values for new objects
+// 
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE        101
+#define _APS_NEXT_COMMAND_VALUE         40001
+#define _APS_NEXT_CONTROL_VALUE         1000
+#define _APS_NEXT_SYMED_VALUE           101
+#endif
+#endif
diff --git a/rosapps/net/telnet/resource/tnmsg.rc b/rosapps/net/telnet/resource/tnmsg.rc
new file mode 100644 (file)
index 0000000..9315571
--- /dev/null
@@ -0,0 +1,107 @@
+#include "tnmsg.h"
+
+LANGUAGE 0,0
+
+// String Table
+STRINGTABLE DISCARDABLE 
+BEGIN
+    MSG_COPYRIGHT           "Telnet Win32 v2.1b2, Copyright (C) 2000 Paul Brannan <pbranna@clemson.edu>\nand the team.  This program comes with ABSOLUTELY NO WARRANTY; for details\nread LICENSE.TXT.  "
+    MSG_COPYRIGHT_1         "This is free software, and you are welcome to redistribute\nit under certain conditions.\n\n"
+    MSG_USAGE               "Usage: TELNET [params][host [port]]\n\n  params\n    -d:FILENAME.EXT  Dumps all incoming data to FILENAME.EXT.\n  host              Host name or IP address of the remote host to connect to.\n"
+    MSG_USAGE_1             "  port              Service port to open (default is telnet port 23).\n\n"
+    MSG_HELP                "Commands may be abbreviated.  Commands are:\n  \ncl[ose]         close current connection\nop[en]          connect to a site\nq[uit]          exit telnet\n"
+    MSG_HELP_1              "ke[ys]          changes/displays keymaps (write keys to see the options)\nse[t]           displays/alters configuration options\nz               suspend\n? h[elp]        print help information\n"
+    MSG_INVCMD              "Invalid command.  Type ? for help.\n"
+    MSG_ERROR               "%1 failed.\n"
+    MSG_INFO                "%1\n"
+    MSG_WARNING             "%1\n"
+    MSG_TRYING              "Trying %1.%2.%3.%4:%5...\n"
+    MSG_CONNECTED           "Connected to %1.  Escape key is ALT-%2.\n"
+    MSG_TERMBYREM           "Connection terminated.\n"
+    MSG_KEYMAP              "Loading %1 from %2.\n"
+    MSG_ERRKEYMAP           "Error loading keymap.\n"
+    MSG_DUMPFILE            "Writing output to file %1.\n"
+    MSG_CONFIG              "Loading configuration options from %1.\n"
+    MSG_NOINI               "Error loading configuration file %1.\nLoading default options.\n"
+    MSG_BADVAL              "Warning: invalid variable %1.\n"
+    MSG_NOSPAWN             "Unable to spawn process.\n"
+    MSG_RESOLVING           "Looking up host: %1..."
+    MSG_NOSERVICE           "Could not find TCP service %1.\n"
+    MSG_SIZEALIAS           "Warning: size of alias %1 is too big, ignoring.\n"
+    MSG_ERRPIPE             "Error: unable to spawn process for pipe.\n"
+    MSG_BADUSAGE            "Error: invalid usage of command.\n"
+    MSG_ALREADYCONNECTED    "Already connected to %1.\n"
+
+    MSG_WSAEINTR            "Interrupted function call.\n"
+    MSG_WSAEBADF            "WSAEBADF\n"
+    MSG_WSAEACCESS          "Permission denied.\n"
+    MSG_WSAEDEFAULT         "WSAEDEFAULT\n"
+    MSG_WSAEINVAL           "Invalid argument.\n"
+    MSG_WSAEMFILE           "Too many open files.\n"
+    MSG_WSAEWOULDBLOCK      "Resource temporalily unavailable.\n"
+    MSG_WSAEINPROGRESS      "Operation now in progress.\n"
+    MSG_WSAEALREADY         "Operation already in progress.\n"
+    MSG_WSAENOTSOCK         "Socket operation on non-socket.\n"
+    MSG_WSAEDESTADDRREQ     "Destination address required.\n"
+    MSG_WSAEMSGSIZE         "Message too long.\n"
+    MSG_WSAEPROTOTYPE       "Protocol wrong type for socket.\n"
+    MSG_WSAENOPROTOOPT      "Bad protocol option.\n"
+    MSG_WSAEPROTONOTSUPPORT "Protocol not supported.\n"
+    MSG_WSAESOCKNOTSUPPORT  "Socket type not supported.\n"
+    MSG_WSAEOPNOTSUPP       "Operation not supported.\n"
+    MSG_WSAEPFNOTSUPPORT    "Protocol family not supported.\n"
+    MSG_WSAEAFNOTSUPPORT    "Address family not supported by protocol family.\n"
+    MSG_WSAEADDRINUSE       "Address already in use.\n"
+    MSG_WSAEADDRNOTAVAIL    "Cannot assign requested address.\n"
+    MSG_WSAENETDOWN         "Network is down.\n"
+    MSG_WSAENETUNREACH      "Network is unreachable.\n"
+    MSG_WSAENETRESET        "Network dropped connection on reset.\n"
+    MSG_WSAECONNABORTED     "Software caused connection abort.\n"
+    MSG_WSAECONNRESET       "Connection reset by peer.\n"
+    MSG_WSAENOBUFS          "No buffer space available.\n"
+    MSG_WSAEISCONN          "Socket is already connected.\n"
+    MSG_WSAENOTCONN         "Socket is not connected.\n"
+    MSG_WSAESHUTDOWN        "Cannot send after socket shutdown.\n"
+    MSG_WSAETOOMANYREFS     "WSAETOOMANYREFS\n"
+    MSG_WSAETIMEDOUT        "Connection timed out.\n"
+    MSG_WSAECONNREFUSED     "Connection refused.\n"
+    MSG_WSAELOOP            "WSAELOOP\n"
+    MSG_WSAENAMETOOLONG     "Name too long.\n"
+    MSG_WSAEHOSTDOWN        "Host is down.\n"
+    MSG_WSAEHOSTUNREACH     "No route to host.\n"
+    MSG_WSAESYSNOTREADY     "Network subsystem is unavailable.\n"
+    MSG_WSAVERNOTSUPPORTED  "WINSOCK.DLL version out of range.\n"
+    MSG_WSANOTINITIALISED   "Successful WSAStartup not yet performed.\n"
+    MSG_WSAHOST_NOT_FOUND   "Host not found.\n"
+    MSG_WSATRY_AGAIN        "Non-authoritative host not found.\n"
+    MSG_WSANO_RECOVERY      "This is a non-recoverable error.\n"
+    MSG_WSANO_DATA          "Valid name, no data record of requested type.\n"
+
+    MSG_KEYNOVAL            "[GLOBAL]: No value for %1.\n"
+    MSG_KEYBADVAL           "[GLOBAL]: Bad value for %1.\n"
+    MSG_KEYBADSTRUCT        "%1: Bad structure.\n"
+    MSG_KEYBADCHARS         "%1: Bad chars? %1 -> %3.\n"
+    MSG_KEYUNEXPLINE        "Unexpected line ""%1"".\n"
+    MSG_KEYUNEXPEOF         "Unexpended end of file.\n"
+    MSG_KEYUNEXPTOK         "Unexpected token %1.\n"
+    MSG_KEYUNEXPTOKIN       "Unexpected token in %1.\n"
+    MSG_KEYUNEXP            "Unexpected end of file or token.\n"
+    MSG_KEYNOGLOBAL         "No [GLOBAL] definition!\n"
+    MSG_KEYNOCONFIG         "No [CONFIG %1].\n"
+    MSG_KEYUSECONFIG        "Use configuration: %1.\n"
+    MSG_KEYNOSWKEY          "No switch key for ""%1"".\n"
+    MSG_KEYCANNOTDEF        "You cannot define switch key for default keymap - ignored.\n"
+    MSG_KEYDUPSWKEY         "Duplicate switching key.\n"
+    MSG_KEYUNKNOWNMAP       "Unknown keymap %1.\n"
+    MSG_KEYNOCHARMAPS       "No charmaps loaded.\n"
+    MSG_KEYNOKEYMAPS        "No keymaps loaded.\n"
+    MSG_KEYNUMMAPS          "There are %1 maps.\n"
+    MSG_KEYBADMAP           "Bad keymap number - try 'keys display'\n"
+    MSG_KEYMAPSWITCHED      "keymap switched.\n"
+END
+
+#if defined(__MINGW32__) || defined(__CYGWIN__)
+TelnetIcon ICON "telnet.ico"
+#else
+TelnetIcon ICON "../telnet.ico"
+#endif
\ No newline at end of file
diff --git a/rosapps/net/telnet/src/ansiprsr.cpp b/rosapps/net/telnet/src/ansiprsr.cpp
new file mode 100644 (file)
index 0000000..6280147
--- /dev/null
@@ -0,0 +1,1474 @@
+///////////////////////////////////////////////////////////////////////////////
+//Telnet Win32 : an ANSI telnet client.
+//Copyright (C) 1998-2000 Paul Brannan
+//Copyright (C) 1998 I.Ioannou
+//Copyright (C) 1997 Brad Johnson
+//
+//This program is free software; you can redistribute it and/or
+//modify it under the terms of the GNU General Public License
+//as published by the Free Software Foundation; either version 2
+//of the License, or (at your option) any later version.
+//
+//This program is distributed in the hope that it will be useful,
+//but WITHOUT ANY WARRANTY; without even the implied warranty of
+//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//GNU General Public License for more details.
+//
+//You should have received a copy of the GNU General Public License
+//along with this program; if not, write to the Free Software
+//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+//I.Ioannou
+//roryt@hol.gr
+//
+///////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Module:             ansiprsr.cpp
+//
+// Contents:   ANSI parser base class
+//
+// Product:            telnet
+//
+// Revisions: August 30, 1998 Paul Brannan <pbranna@clemson.edu>
+//            July 29, 1998 pbranna@clemson.edu
+//            June 15, 1998 pbranna@clemson.edu
+//            May 19, 1998  pbranna@clemson.edu
+//            24 Dec, 1997  Andrey.V.Smilianets
+//            05. Sep.1997  roryt@hol.gr (I.Ioannou)
+//            11.May.1997   roryt@hol.gr (I.Ioannou)
+//            6.April.1997  roryt@hol.gr (I.Ioannou)
+//            5.April.1997  jbj@nounname.com
+//            30.M\84rz.1997     Titus_Boxberg@public.uni-hamburg.de
+//                   14.Sept.1996  jbj@nounname.com
+//            Version 2.0
+//
+//            13.Jul.1995      igor.milavec@uni-lj.si
+//                                       Original code
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#include <windows.h>
+#include <string.h>
+#include "ansiprsr.h"
+
+// The constructor now takes different arguments and initializes different
+// variables (Paul Brannan 6/15/98)
+TANSIParser::TANSIParser(TConsole &RefConsole, KeyTranslator &RefKeyTrans,
+                                                TScroller &RefScroller, TNetwork &RefNetwork,
+                                                TCharmap &RefCharmap):
+TParser(RefConsole, RefKeyTrans, RefScroller, RefNetwork, RefCharmap) {
+       Init();
+       iSavedAttributes = (unsigned char) 7;
+       // must also check to make sure the string is non-NULL
+       // (Paul Brannan 5/8/98)
+       if ((ini.get_dumpfile() != NULL) && (*ini.get_dumpfile() != '\0')){
+               dumpfile = fopen(ini.get_dumpfile(), "wb");
+       }else {
+               dumpfile = NULL;
+       }
+       InPrintMode = 0;
+       printfile = NULL;
+
+       fast_write = ini.get_fast_write(); // Paul Brannan 6/28/98
+       Scroller.init(&StripBuffer);
+}
+
+TANSIParser::~TANSIParser(){
+       if (dumpfile) fclose (dumpfile);
+       // Added I.Ioannou 06 April, 1997
+       if (printfile != NULL) fclose (printfile);
+}
+
+// Created Init() function to initialize the parser but not clear the screen
+// (Paul Brannan 9/23/98)
+void TANSIParser::Init() {
+       // Paul Brannan 6/25/98
+       map_G0 = 'B'; map_G1 = 'B';
+       Charmap.setmap(map_G0);
+       current_map = 'B';
+
+       ignore_margins = 0;
+       vt52_mode = 0;
+       print_ctrl = 0;
+       newline_mode = false;
+
+       KeyTrans.clear_ext_mode();
+
+       iSavedCurY = 0;                                                 // Reset Variables
+       iSavedCurX = 0;
+       inGraphMode = 0;
+       Console.SetScroll(-1, -1);
+       Console.Normal();                                               // Reset Attributes
+
+       // Set tabs stops
+       resetTabStops();
+}
+
+void TANSIParser::ResetTerminal() {
+       Init();
+       Console.ClearScreen();                                  // Clear Screen
+       Console.SetRawCursorPosition(0,0);              // Home Cursor
+}
+void TANSIParser::SaveCurY(int iY){
+       iSavedCurY=iY;
+}
+
+void TANSIParser::SaveCurX(int iX){
+       iSavedCurX=iX;
+}
+
+void TANSIParser::resetTabStops() {
+       for(int j = 0; j < MAX_TAB_POSITIONS; j++) {
+               tab_stops[j] = 8 + j - (j%8);
+       }
+}
+
+void TANSIParser::ConSetAttribute(unsigned char TextAttrib){
+       // Paul Brannan 5/8/98
+       // Made this go a little bit faster by changing from switch{} to an array
+       // for the colors
+       if(TextAttrib >= 30) {
+               if(TextAttrib <= 37) {
+                       Console.SetForeground(ANSIColors[TextAttrib-30]);
+                       return;
+               } else if((TextAttrib >= 40) && (TextAttrib <= 47)) {
+                       Console.SetBackground(ANSIColors[TextAttrib-40]);
+                       return;
+               }
+       }
+       
+       switch (TextAttrib){
+               // Text Attributes
+       case 0: Console.Normal();           break;      // Normal video
+       case 1: Console.HighVideo();        break;      // High video
+       case 2: Console.LowVideo();         break;      // Low video
+       case 4: Console.UnderlineOn();          break;  // Underline on (I.Ioannou)
+       case 5: Console.BlinkOn();                      break;  // Blink video
+               // Corrected by I.Ioannou 11 May, 1997
+       case 7: Console.ReverseOn();            break;  // Reverse video
+       case 8:                                                         break;  // hidden
+               // All from 10 thru 27 are hacked from linux kernel
+               // I.Ioannou 06 April, 1997
+       case 10:
+               //  I.Ioannou 04 Sep 1997 turn on/off high bit
+               inGraphMode = 0;
+               print_ctrl = 0;
+               Charmap.setmap(current_map ? map_G1:map_G0); // Paul Brannan 6/25/98
+               break; // ANSI X3.64-1979 (SCO-ish?)
+               // Select primary font,
+               // don't display control chars
+               // if defined, don't set
+               // bit 8 on output (normal)
+       case 11:
+               inGraphMode = 0;
+               print_ctrl = 1;
+               Charmap.setmap(0); // Paul Brannan 6/25/98
+               break; // ANSI X3.64-1979 (SCO-ish?)
+               // Select first alternate font,
+               // let chars < 32 be displayed
+               // as ROM chars
+       case 12:
+               inGraphMode = 1;
+               print_ctrl = 1;
+               Charmap.setmap(0); // Paul Brannan 6/25/98
+               break; // ANSI X3.64-1979 (SCO-ish?)
+               // Select second alternate font,
+               // toggle high bit before
+               // displaying as ROM char.
+               
+       case 21:                                                                        // not really Low video
+       case 22: Console.LowVideo();            break;  // but this works good also
+       case 24: Console.UnderlineOff();        break;  // Underline off
+       case 25: Console.BlinkOff();            break;  // blink off
+               // Corrected by I.Ioannou 11 May, 1997
+       case 27: Console.ReverseOff();          break;  //Reverse video off
+
+       // Mutt needs this (Paul Brannan, Peter Jordan 12/31/98)
+       // This is from the Linux kernel source
+    case 38: /* ANSI X3.64-1979 (SCO-ish?)
+                         * Enables underscore, white foreground
+                         * with white underscore (Linux - use
+                         * default foreground).
+                         */
+                       Console.UnderlineOn();
+                       Console.SetForeground(ini.get_normal_fg());
+                       break;
+       case 39: /* ANSI X3.64-1979 (SCO-ish?)
+                         * Disable underline option.
+                         * Reset colour to default? It did this
+                         * before...
+                         */
+                       Console.UnderlineOff();
+                       Console.SetForeground(ini.get_normal_fg());
+                       break;
+       case 49:
+                       Console.SetBackground(ini.get_normal_bg());
+                       break;
+
+       }
+}
+
+void TANSIParser::ConSetCursorPos(int x, int y) {
+       if(ignore_margins)
+               Console.SetRawCursorPosition(x, y);
+       else
+               Console.SetCursorPosition(x, y);
+}
+
+char* TANSIParser::GetTerminalID()
+{
+       return "\033[?1;2c";
+}
+
+// All of the Telnet protocol stuff has been moved to TTelHndl.cpp
+// This is more consistent with what OO should be
+// (Paul Brannan 6/15/98)
+
+#ifdef __BORLANDC__
+// argsused doesn't work on MSVC++
+#pragma argsused
+#endif
+
+// Use this for the VT100 flags (Paul Brannan 12/2/98)
+#define FLAG_DOLLAR            0x0001
+#define FLAG_QMARK             0x0002
+#define FLAG_GREATER   0x0004
+#define FLAG_LESS              0x0008
+#define FLAG_EXCLAM            0x0010
+#define FLAG_AMPERSAND 0x0020
+#define FLAG_SLASH             0x0040
+#define FLAG_EQUAL             0x0080
+#define FLAG_QUOTE             0x0100
+#define FLAG_OTHER             0x8000
+
+char* TANSIParser::ParseEscapeANSI(char* pszBuffer, char* pszBufferEnd)
+{
+       
+       //      The buffer contains something like <ESC>[pA
+       //      where p is an optional decimal number specifying the count by which the
+       //      appropriate action should take place.
+       //      The pointer pszBuffer points us to the p, <ESC> and [ are
+       //      already 'consumed'
+       
+       //      TITUS: Simplification of the code: Assume default count of 1 in case
+       //      there are no parameters.
+       char tmpc;
+       const int nParam = 10;  // Maximum number of parameters
+       int     iParam[nParam] = {1, 0, 0, 0, 0};       // Assume 1 Parameter, Default 1
+       int iCurrentParam = 0;
+       DWORD flag = 0;
+       int missing_param = 0;
+
+       // Get parameters from escape sequence.
+       while ((tmpc = *pszBuffer) <= '?') {
+
+               if(tmpc < '0' || tmpc > '9') {
+                       // Check for parameter delimiter.
+                       if(tmpc == ';') {
+                               // This is a hack (Paul Brannan 6/27/98)
+                               if(*(pszBuffer - 1) == '[') missing_param = iCurrentParam+1;
+                               pszBuffer++;
+                               continue;
+                       }
+
+                       // It is legal to have control characters inside ANSI sequences
+                       // (Paul Brannan 6/26/98)
+                       if(tmpc < ' ') {
+                               Console.WriteCtrlChar(tmpc);
+                               pszBuffer++;
+                               continue;
+                       }
+
+                       // A new way of handling flags (Paul Brannan 12/2/98)
+                       switch(tmpc) {
+                       case '$': flag |= FLAG_DOLLAR; break;
+                       case '?': flag |= FLAG_QMARK; break;
+                       case '>': flag |= FLAG_GREATER; break;
+                       case '<': flag |= FLAG_LESS; break;
+                       case '!': flag |= FLAG_EXCLAM; break;
+                       case '&': flag |= FLAG_AMPERSAND; break;
+                       case '/': flag |= FLAG_SLASH; break;
+                       case '=': flag |= FLAG_EQUAL; break;
+                       case '\"': flag |= FLAG_QUOTE; break;
+                       default: flag |= FLAG_OTHER; break;
+                       }
+
+                       pszBuffer++;
+               }
+
+               //  Got Numerical Parameter.
+               iParam[iCurrentParam] = strtoul(pszBuffer, &pszBuffer, 10);
+               if (iCurrentParam < nParam)
+                       iCurrentParam++;
+       }
+       
+       //~~~ TITUS: Apparently the digit is optional (look at termcap or terminfo)
+       // So: If there is no digit, assume a count of 1
+       
+       switch ((unsigned char)*pszBuffer++) {
+               // Insert Character
+               case '@':
+                       if(iParam[0] == 0) iParam[0] = 1; // Paul Brannan 9/1/98
+                       Console.InsertCharacter(iParam[0]); break;
+               // Move cursor up.
+               case 'A':
+                       if(iParam[0] == 0) iParam[0] = 1;
+                       Console.MoveCursorPosition(0, -iParam[0]); break;
+               // Move cursor down.
+               // Added by I.Ioannou 06 April, 1997
+               case 'B':
+               case 'e':
+                       if(iParam[0] == 0) iParam[0] = 1;
+                       Console.MoveCursorPosition(0, iParam[0]);
+                       break;
+               // Move cursor right.
+               // Added by I.Ioannou 06 April, 1997
+               case 'C':
+               case 'a':
+                       // Handle cursor size sequences (Jose Cesar Otero Rodriquez and
+                       // Paul Brannan, 3/27/1999)
+                       if(flag & FLAG_EQUAL) {
+                               switch(iParam[0]) {
+                               case 7: Console.SetCursorSize(50); break;
+                               case 11: Console.SetCursorSize(6); break;
+                               case 32: Console.SetCursorSize(0); break;
+                               default: Console.SetCursorSize(13);
+                               }
+                       } else {
+                               if(iParam[0] == 0) iParam[0] = 1;
+                               Console.MoveCursorPosition(iParam[0], 0);
+                               break;
+                       }
+               // Move cursor left.
+               case 'D':
+                       if(iParam[0] == 0) iParam[0] = 1;
+                       Console.MoveCursorPosition(-iParam[0], 0);
+                       break;
+               // Move cursor to beginning of line, p lines down.
+               // Added by I.Ioannou 06 April, 1997
+               case 'E': 
+                       Console.MoveCursorPosition(-Console.GetCursorX(), iParam[0]);
+                       break;
+               // Moves active position to beginning of line, p lines up
+               // Added by I.Ioannou 06 April, 1997
+               // With '=' this changes the default fg color (Paul Brannan 6/27/98)
+               case 'F':
+                       if(flag & FLAG_EQUAL)
+                               Console.setDefaultFg(iParam[0]);
+                       else
+                               Console.MoveCursorPosition(-Console.GetCursorX(), -iParam[0]);
+                       break;
+               // Go to column p
+               // Added by I.Ioannou 06 April, 1997
+               // With '=' this changes the default bg color (Paul Brannan 6/27/98)
+               case '`': 
+               case 'G': // 'G' is from Linux kernel sources
+                       if(flag & FLAG_EQUAL) {
+                               Console.setDefaultBg(iParam[0]);
+                       } else {
+                               if (iCurrentParam < 1)                  // Alter Default
+                                       iParam[0] = 0;
+                               // this was backward, and we should subtract 1 from x
+                               // (Paul Brannan 5/27/98)
+                               ConSetCursorPos(iParam[0] - 1, Console.GetCursorY());
+                       }
+                       break;
+               // Set cursor position.
+               case 'f': 
+               case 'H':
+                       if (iCurrentParam < 2 || iParam[1] < 1)
+                               iParam[1] = 1;
+                       ConSetCursorPos(iParam[1] - 1, iParam[0] - 1);
+                       break;
+               // Clear screen
+               case 'J': 
+                       if ( iCurrentParam < 1 ) iParam[0] = 0; // Alter Default
+                       switch (iParam[0]) {
+                               case 0: Console.ClearEOScreen(); break;
+                               case 1: Console.ClearBOScreen(); break;
+                               case 2:
+                                       Console.ClearScreen();
+                                       Console.SetRawCursorPosition(0, 0);
+                                       break;
+                       }
+                       break;
+               // Clear line
+               case 'K': 
+                       if (iCurrentParam < 1)                  // Alter Default
+                               iParam[0] = 0;
+                       switch (iParam[0]) {
+                               case 0: Console.ClearEOLine(); break;
+                               case 1: Console.ClearBOLine(); break;
+                               case 2: Console.ClearLine(); break;
+                       }
+                       break;
+               //  Insert p new, blank lines.
+               // Added by I.Ioannou 06 April, 1997
+               case 'L': 
+                       {
+                               // for (int i = 1; i <= iParam[0]; i++)
+                               // This should speed things up a bit (Paul Brannan 9/2/98)
+                               Console.ScrollDown(Console.GetRawCursorY(), -1, iParam[0]);
+                               break;
+                       }
+               //  Delete p lines.
+               // Added by I.Ioannou 06 April, 1997
+               case 'M': 
+                       {
+                               for (int i = 1; i <= iParam[0]; i++)
+                               // This should speed things up a bit (Paul Brannan 9/2/98)
+                               Console.ScrollDown(Console.GetRawCursorY(), -1, -1);
+                               break;
+                       }
+               // DELETE CHAR
+               case 'P': 
+                       Console.DeleteCharacter(iParam[0]);
+                       break;
+               // Scrolls screen up (down? -- PB) p lines,
+               // Added by I.Ioannou 06 April, 1997
+               // ANSI X3.64-1979 references this but I didn't
+               // found it in any telnet implementation
+               // note 05 Oct 97  : but SCO terminfo uses them, so uncomment them !!
+               case 'S': 
+                       {
+                               //for (int i = 1; i <= iParam[0]; i++)
+                               // This should speed things up a bit (Paul Brannan 9/2/98)
+                               Console.ScrollDown(-1, -1, -iParam[0]);
+                               break;
+                       }
+               // Scrolls screen up p lines,
+               // Added by I.Ioannou 06 April, 1997
+               // ANSI X3.64-1979 references this but I didn't
+               // found it in any telnet implementation
+               // note 05 Oct 97  : but SCO terminfo uses them, so uncomment them !!
+               case 'T': 
+                       {
+                               // for (int i = 1; i <= iParam[0]; i++)
+                               // This should speed things up a bit (Paul Brannan 9/2/98)
+                               Console.ScrollDown(-1, -1, iParam[0]);
+                               break;
+                       }
+               //  Erases p characters up to the end of line
+               // Added by I.Ioannou 06 April, 1997
+               case 'X': 
+                       {
+                               int iKeepX = Console.GetRawCursorX();
+                               int iKeepY = Console.GetRawCursorY();
+                               if (iParam[0] > Console.GetWidth())
+                                       iParam[0] = Console.GetWidth(); // up to the end of line
+                               for ( int i = 1; i <= iParam[0]; i++ )
+                                       Console.WriteString(" ", 1);
+                               Console.SetRawCursorPosition(iKeepX , iKeepY);
+                               break;
+                       }
+               // Go back p tab stops
+               // Added by I.Ioannou 06 April, 1997
+               // Implemented by Paul Brannan, 4/13/2000
+               case 'Z':
+                       {
+                               int x = Console.GetCursorX();
+                               for(int j = 0; x > 0 && j < iParam[0]; j++)
+                                       while(x > 0 && tab_stops[j] == tab_stops[x]) x--;
+                               Console.SetCursorPosition(x, Console.GetCursorY());
+                       }
+                       break;
+               // Get Terminal ID
+               case 'c': 
+                       {
+                               char* szTerminalId = GetTerminalID();
+                               Network.WriteString(szTerminalId, strlen(szTerminalId));
+                               break;
+                       }
+               // TITUS++ 2. November 1998: Repeat Character.
+               case 'b':
+                       // isprint may be causing problems (Paul Brannan 3/27/99)
+                       // if ( isprint(last_char) ) {
+                               char    buf[150];       // at most 1 line (max 132 chars)
+
+                               if ( iParam[0] > 149 ) iParam[0] = 149;
+                               memset(buf, last_char, iParam[0]);
+                               buf[iParam[0]] = 0;
+                               if ( fast_write )
+                                       Console.WriteStringFast(buf, iParam[0]);
+                               else
+                                       Console.WriteString(buf, iParam[0]);
+                       // } /* IF */
+               break;
+               // Go to line p
+               // Added by I.Ioannou 06 April, 1997
+               case 'd': 
+                       if (iCurrentParam < 1)                  // Alter Default
+                               iParam[0] = 0;
+                       // this was backward, and we should subtract 1 from y
+                       // (Paul Brannan 5/27/98)
+                       ConSetCursorPos(Console.GetCursorX(), iParam[0] - 1);
+                       break;
+               // iBCS2 tab erase
+               // Added by I.Ioannou 06 April, 1997
+               case 'g': 
+                       if (iCurrentParam < 1)                  // Alter Default
+                               iParam[0] = 0;
+                       switch (iParam[0]) {
+                               case 0:
+                                       {
+                                               // Clear the horizontal tab stop at the current active position
+                                               for(int j = 0; j < MAX_TAB_POSITIONS; j++) {
+                                                       int x = Console.GetCursorX();
+                                                       if(tab_stops[j] == x) tab_stops[j] = tab_stops[x + 1];
+                                               }
+                                       }
+                                       break;
+                               case 2:
+                                       // I think this might be "set as default?"
+                                       break;
+                               case 3:
+                                       {
+                                               // Clear all tab stops
+                                               for(int j = 0; j < MAX_TAB_POSITIONS; j++)
+                                                       tab_stops[j] = -1;
+                                       }
+                                       break;
+                       }
+                       break;
+               // Set extended mode
+               case 'h': 
+                       {
+                               for (int i = 0; i < iCurrentParam; i++) {
+                                       // Changed to a switch statement (Paul Brannan 5/27/98)
+                                       if(flag & FLAG_QMARK) {
+                                               switch(iParam[i]) {
+                                                       case 1: // App cursor keys
+                                                               KeyTrans.set_ext_mode(APP_KEY);
+                                                               break;
+                                                       case 2: // VT102 mode
+                                                               vt52_mode = 0;
+                                                               KeyTrans.unset_ext_mode(APP2_KEY);
+                                                               break;
+                                                       case 3: // 132 columns
+                                                               if(ini.get_wide_enable()) {
+                                                                       Console.SetWindowSize(132, -1);
+                                                               }
+                                                               break;
+                                                       case 4: // smooth scrolling
+                                                               break;
+                                                       case 5: // Light background
+                                                               Console.Lightbg();
+                                                               break;
+                                                       case 6: // Stay in margins
+                                                               ignore_margins = 0;
+                                                               break;
+                                                       case 7:
+                                                               Console.setLineWrap(true);
+                                                               break;
+                                                       case 8: // Auto-repeat keys
+                                                               break;
+                                                       case 18: // Send FF to printer
+                                                               break;
+                                                       case 19: // Entire screen legal for printer
+                                                               break;
+                                                       case 25: // Visible cursor
+                                                               break;
+                                                       case 66: // Application numeric keypad
+                                                               break;
+                                                       default:
+#ifdef DEBUG
+                                                               Console.Beep();
+#endif
+                                                               break;
+                                               }
+                                       } else {
+                                               switch(iParam[i]) {
+                                                       case 2: // Lock keyboard
+                                                               break;
+                                                       case 3: // Act upon control codes (PB 12/5/98)
+                                                               print_ctrl = 0;
+                                                               break;
+                                                       case 4: // Set insert mode
+                                                               Console.InsertMode(1);
+                                                               break;
+                                                       case 12: // Local echo off
+                                                               break;
+                                                       case 20: // Newline sends cr/lf
+                                                               KeyTrans.set_ext_mode(APP4_KEY);
+                                                               newline_mode = true;
+                                                               break;
+                                                       default:
+#ifdef DEBUG
+                                                               Console.Beep();
+#endif
+                                                               break;
+                                               }
+                                       }
+                               }
+                       }
+                       break;
+               // Print Screen
+               case 'i': 
+                       if (iCurrentParam < 1)
+                               iParam[0]=0;
+                       switch (iParam[0]){
+                               case 0: break; // Print Screen
+                               case 1: break; // Print Line
+                               // Added I.Ioannou 06 April, 1997
+                               case 4:
+                                       // Stop Print Log
+                                       InPrintMode = 0;
+                                       if ( printfile != NULL )
+                                               fclose(printfile);
+                                       break;
+                               case 5:
+                                       // Start Print Log
+                                       printfile = fopen(ini.get_printer_name(), "ab");
+                                       if (printfile != NULL) InPrintMode = 1;
+                                       break;
+                       }
+                       break;
+               // Unset extended mode
+               case 'l': 
+                       {
+                               for (int i = 0; i < iCurrentParam; i++) {
+                                       // Changed to a switch statement (Paul Brannan 5/27/98)
+                                       if(flag & FLAG_QMARK) {
+                                               switch(iParam[i]) {
+                                                       case 1: // Numeric cursor keys
+                                                               KeyTrans.unset_ext_mode(APP_KEY);
+                                                               break;
+                                                       case 2: // VT52 mode
+                                                               vt52_mode = 1;
+                                                               KeyTrans.set_ext_mode(APP2_KEY);
+                                                               break;
+                                                       case 3: // 80 columns
+                                                               if(ini.get_wide_enable()) {
+                                                                       Console.SetWindowSize(80, -1);
+                                                               }
+                                                               break;
+                                                       case 4: // jump scrolling
+                                                               break;
+                                                       case 5: // Dark background
+                                                               Console.Darkbg();
+                                                               break;
+                                                       case 6: // Ignore margins
+                                                               ignore_margins = 1;
+                                                               break;
+                                                       case 7:
+                                                               Console.setLineWrap(false);
+                                                               break;
+                                                       case 8: // Auto-repeat keys
+                                                               break;
+                                                       case 19: // Only send scrolling region to printer
+                                                               break;
+                                                       case 25: // Invisible cursor
+                                                               break;
+                                                       case 66: // Numeric keypad
+                                                               break;
+                                                       default:
+#ifdef DEBUG
+                                                               Console.Beep();
+#endif
+                                                               break;
+                                               }
+                                       } else {
+                                               switch(iParam[i]) {
+                                                       case 2: // Unlock keyboard
+                                                               break;
+                                                       case 3: // Display control codes (PB 12/5/98)
+                                                               print_ctrl = 1;
+                                                               break;
+                                                       case 4: // Set overtype mode
+                                                               Console.InsertMode(0);
+                                                               break;
+                                                       case 12: // Local echo on
+                                                               break;
+                                                       case 20: // sends lf only
+                                                               KeyTrans.unset_ext_mode(APP4_KEY);
+                                                               newline_mode = false;
+                                                               break;
+                                                       default:
+#ifdef DEBUG
+                                                               Console.Beep();
+#endif
+                                                               break;
+                                               }
+                                       }
+                               }
+                       }
+                       break;
+               // Set color
+               case 'm':
+                       if(missing_param) Console.Normal();
+                       if(iCurrentParam == 0) {
+                               Console.Normal();
+                       } else {
+                               for(int i = 0; i < iCurrentParam; i++)
+                                       ConSetAttribute(iParam[i]);
+                       }
+                       break;
+               // report cursor position Row X Col
+               case 'n': 
+                       if (iCurrentParam == 1 && iParam[0]==5) {
+                               // report the cursor position
+                               Network.WriteString("\x1B[0n", 6);
+                               break;
+                       }
+                       if (iCurrentParam == 1 && iParam[0]==6){
+                               // report the cursor position
+                               // The cursor position needs to be sent as a single string
+                               // (Paul Brannan 6/27/98)
+                               char szCursorReport[40] = "\x1B[";
+
+                               itoa(Console.GetCursorY() + 1,
+                                       &szCursorReport[strlen(szCursorReport)], 10);
+                               strcat(szCursorReport, ";");
+                               itoa(Console.GetCursorX() + 1,
+                                       &szCursorReport[strlen(szCursorReport)], 10);
+                               strcat(szCursorReport, "R");
+
+                               Network.WriteString(szCursorReport, strlen(szCursorReport));
+               
+                       }
+                       break;
+               // Miscellaneous weird sequences (Paul Brannan 6/27/98)
+               case 'p':
+                       // Set conformance level
+                       if(flag & FLAG_QUOTE) {
+                               break;
+                       }
+                       // Soft terminal reset
+                       if(flag & FLAG_EXCLAM) {
+                               break;
+                       }
+                       // Report mode settings
+                       if(flag & FLAG_DOLLAR) {
+                               break;
+                       }
+                       break;
+               // Scroll Screen
+               case 'r': 
+                       if (iCurrentParam < 1) {
+                               // Enable scrolling for entire display
+                               Console.SetScroll(-1, -1);
+                               break;
+                       }
+                       if (iCurrentParam >1) {
+                               // Enable scrolling from row1 to row2
+                               Console.SetScroll(iParam[0] - 1, iParam[1] - 1);
+                               // If the cursor is outside the scrolling range, fix it
+                               // (Paul Brannan 6/26/98)
+                               // if(Console.GetRawCursorY() < iParam[0] - 1) {
+                               //      Console.SetRawCursorPosition(Console.GetCursorX(),
+                               //              iParam[0] - 1);
+                               // }
+                               // if(Console.GetRawCursorY() > iParam[1] - 1) {
+                               //      Console.SetRawCursorPosition(Console.GetCursorX(),
+                               //              iParam[1] - 1);
+                               // }
+                       }
+                       // Move the cursor to the home position (Paul Brannan 12/2/98)
+                       Console.SetCursorPosition(0, 0);
+                       break;
+               // Save cursor position
+               case 's': 
+                       SaveCurY(Console.GetRawCursorY());
+                       SaveCurX(Console.GetRawCursorX());
+                       break;
+               // Restore cursor position
+               case 'u': 
+                       Console.SetRawCursorPosition(iSavedCurX, iSavedCurY);
+                       break;
+               // DEC terminal report (Paul Brannan 6/28/98)
+               case 'x':
+                       if(iParam[0])
+                               Network.WriteString("\033[3;1;1;128;128;1;0x", 20);
+                       else
+                               Network.WriteString("\033[2;1;1;128;128;1;0x", 20);
+                       break;
+               default:
+#ifdef DEBUG
+                       Console.Beep();
+#endif
+                       break;
+       }
+
+       return pszBuffer;
+}
+
+#ifdef MTE_SUPPORT
+// Added by Frediano Ziglio, 5/31/2000
+// MTE extension
+// initially copied from ParseEscapeANSI
+char* TANSIParser::ParseEscapeMTE(char* pszBuffer, char* pszBufferEnd)
+{
+       //      The buffer contains something like <ESC>~pA
+       //      where p is an optional decimal number specifying the count by which the
+       //      appropriate action should take place.
+       //      The pointer pszBuffer points us to the p, <ESC> and ~ are
+       //      already 'consumed'
+       //      TITUS: Simplification of the code: Assume default count of 1 in case
+       //      there are no parameters.
+       char tmpc;
+       const int nParam = 10;  // Maximum number of parameters
+       int     iParam[nParam] = {1, 0, 0, 0, 0};       // Assume 1 parameter, Default 1
+       int iCurrentParam = 0;
+       char sRepeat[2];
+       
+       // Get parameters from escape sequence.
+       while ((tmpc = *pszBuffer) <= '?') {
+               if(tmpc < '0' || tmpc > '9') {
+                       // Check for parameter delimiter.
+                       if(tmpc == ';') {
+                               pszBuffer++;
+                               continue;
+                       }
+                       pszBuffer++;
+               }
+               
+               //  Got Numerical Parameter.
+               iParam[iCurrentParam] = strtoul(pszBuffer, &pszBuffer, 10);
+               if (iCurrentParam < nParam)
+                       iCurrentParam++;
+       }
+       
+       //~~~ TITUS: Apparently the digit is optional (look at termcap or terminfo)
+       // So: If there is no digit, assume a count of 1
+       
+       switch ((unsigned char)*pszBuffer++) {
+               case 'A':
+                       // set colors
+                       if (iCurrentParam < 2 )
+                               break;
+                       if (iParam[0] <= 15 && iParam[1] <= 15)
+                               Console.SetAttrib( (iParam[1] << 4) | iParam[0] );
+                       break;
+                       
+               case 'R':
+                       // define region
+                       mteRegionXF = -1;
+                       if (iCurrentParam < 2 )
+                               break;
+                       mteRegionXF = iParam[1]-1;
+                       mteRegionYF = iParam[0]-1;
+                       break;
+                       
+               case 'F':
+                       // fill with char
+                       {
+                               if (mteRegionXF == -1 || iCurrentParam < 1)
+                                       break;
+                               sRepeat[0] = (char)iParam[0];
+                               sRepeat[1] = '\0';
+                               int xi = Console.GetCursorX(),yi = Console.GetCursorY();
+                               int xf = mteRegionXF;
+                               int yf = mteRegionYF;
+                               mteRegionXF = -1;
+                               for(int y=yi;y<=yf;++y)
+                               {
+                                       Console.SetCursorPosition(xi,y);
+                                       for(int x=xi;x<=xf;++x)
+                                               
+                                               Console.WriteStringFast(sRepeat,1);
+                               }
+                       }
+                       break;
+                       
+               case 'S':
+                       // Scroll region
+                       {
+                               if (mteRegionXF == -1 || iCurrentParam < 2)
+                                       break;
+                               int /*x = Console.GetCursorX(),*/y = Console.GetCursorY();
+                               // int xf = mteRegionXF;
+                               int yf = mteRegionYF;
+                               mteRegionXF = -1;
+                               // !!! don't use x during scroll
+                               int diff = (iParam[0]-1)-y;
+                               if (diff<0)
+                                       Console.ScrollDown(y-1,yf,diff);
+                               else
+                                       Console.ScrollDown(y,yf+1,diff);
+                       }
+                       break;
+                       // Meridian main version ??
+               case 'x':
+                       // disable echo and line mode
+                       Network.set_local_echo(0);
+                       Network.set_line_mode(0);
+                       // Meridian Server handle cursor itself
+                       Console.SetCursorSize(0);
+                       break;
+                       // query ??
+               case 'Q':
+                       if (iParam[0] == 1)
+                               Network.WriteString("\033vga.",5);
+                       break;
+               default:
+#ifdef DEBUG
+                       Console.Beep();
+#endif
+                       break;
+       }
+       
+       return pszBuffer;
+ }
+#endif
+
+char* TANSIParser::ParseEscape(char* pszBuffer, char* pszBufferEnd) {
+       char *pszChar;
+
+       // Check if we have enough characters in buffer.
+       if ((pszBufferEnd - pszBuffer) < 2)
+               return pszBuffer;
+       
+       //  I.Ioannou 04 Sep 1997
+       // there is no need for pszBuffer++; after each command
+       
+       // Decode the command.
+       pszBuffer++;
+       
+       switch (*pszBuffer++) {
+               case 'A': // Cursor up
+                       Console.MoveCursorPosition(0, -1);
+                       break;
+               // Cursor down
+               case 'B': 
+                       Console.MoveCursorPosition(0, 1);
+                       break;
+               // Cursor right
+               case 'C':
+                       Console.MoveCursorPosition(1, 0);
+                       break;
+               // LF *or* cursor left (Paul Brannan 6/27/98)
+               case 'D':
+                       if(vt52_mode)
+                               Console.MoveCursorPosition(-1, 0);
+                       else
+                               Console.index();
+                       break;
+               // CR/LF (Paul Brannan 6/26/98)
+               case 'E':
+                       Console.WriteCtrlString("\r\n", 2);
+                       break;
+               // Special graphics char set (Paul Brannan 6/27/98)
+               case 'F':
+                       Charmap.setmap('0');
+                       break;
+               // ASCII char set (Paul Brannan 6/27/98)
+               case 'G':
+                       Charmap.setmap('B');
+                       break;
+               // Home cursor/tab set
+               case 'H': 
+                       if(ini.get_vt100_mode()) {
+                               int x = Console.GetCursorX();
+                               if(x != 0) {
+                                       int t = tab_stops[x - 1];
+                                       for(int j = x - 1; j >= 0 && tab_stops[j] == t; j--)
+                                               tab_stops[j] = x;
+                               }
+                       } else {
+                               //  I.Ioannou 04 Sep 1997 (0,0) not (1,1)
+                               ConSetCursorPos(0, 0);
+                       }
+                       break;
+               // Reverse line feed (Paul Brannan 6/27/98)
+               // FIX ME!!!  reverse_index is wrong to be calling here
+               // (Paul Brannan 12/2/98)
+               case 'I':
+                       Console.reverse_index();
+                       break;
+               // Erase end of screen
+               case 'J': 
+                       Console.ClearEOScreen();
+                       break;
+               // Erase EOL
+               case 'K':
+                       Console.ClearEOLine();
+                       break;
+               // Scroll Up one line //Reverse index
+               case 'M':
+                       Console.reverse_index();
+                       break;
+               // Direct cursor addressing
+               case 'Y':
+                       if ((pszBufferEnd - pszBuffer) >= 2){
+                               // if we subtract '\x1F', then we may end up with a negative
+                               // cursor position! (Paul Brannan 6/26/98)
+                               ConSetCursorPos(pszBuffer[1] - ' ',     pszBuffer[0] - ' ');
+                               pszBuffer+=2;
+                       } else {
+                               pszBuffer--; // Paul Brannan 6/26/98
+                       }
+                       break;
+               // Terminal ID Request
+               case 'Z':
+                       {
+                               char* szTerminalId = GetTerminalID();
+                               Network.WriteString(szTerminalId, strlen(szTerminalId));
+                               break;
+                       }
+               // reset terminal to defaults
+               case 'c':
+                       ResetTerminal();
+                       break;
+               // Enter alternate keypad mode
+               case '=':
+                       KeyTrans.set_ext_mode(APP3_KEY);
+                       break;
+               // Exit alternate keypad mode
+               case '>':
+                       KeyTrans.unset_ext_mode(APP3_KEY);
+                       break;
+               // Enter ANSI mode
+               case '<':
+                       KeyTrans.unset_ext_mode(APP2_KEY); // exit vt52 mode
+                       break;
+               // Graphics processor on (See note 3)
+               case '1':
+                       break;
+               // Line size commands
+               case '#':        //Line size commands
+                       // (Paul Brannan 6/26/98)
+                       if(pszBuffer < pszBufferEnd) {
+                               switch(*pszBuffer++) {
+                               case '3': break; // top half of a double-height line
+                               case '4': break; // bottom half of a double-height line
+                               case '6': break; // current line becomes double-width
+                               case '8': Console.ClearScreen('E'); break;
+                               }
+                       } else {
+                               pszBuffer--;
+                       }                       
+                       break;
+               // Graphics processor off (See note 3)
+               case '2':
+                       break;
+               // Save cursor and attribs
+               case '7':
+                       SaveCurY(Console.GetRawCursorY());
+                       SaveCurX(Console.GetRawCursorX());
+                       iSavedAttributes = Console.GetAttrib();
+                       break;
+                       // Restore cursor position and attribs
+               case '8':
+                       Console.SetRawCursorPosition(iSavedCurX, iSavedCurY);
+                       Console.SetAttrib(iSavedAttributes);
+                       break;
+               // Set G0 map (Paul Brannan 6/25/98)
+               case '(':
+                       if (pszBuffer < pszBufferEnd) {
+                               map_G0 = *pszBuffer;
+                               if(current_map == 0) Charmap.setmap(map_G0);
+                               pszBuffer++;
+                       } else {
+                               pszBuffer--;
+                       }
+                       break;
+               // Set G1 map (Paul Brannan 6/25/98)
+               case ')':
+                       if (pszBuffer < pszBufferEnd) {
+                               map_G1 = *pszBuffer;
+                               if(current_map == 1) Charmap.setmap(map_G1);
+                               pszBuffer++;
+                       } else {
+                               pszBuffer--;
+                       }
+                       break;
+               // This doesn't do anything, as far as I can tell, but it does take
+               // a parameter (Paul Brannan 6/27/98)
+               case '%':
+                       if (pszBuffer < pszBufferEnd) {
+                               pszBuffer++;
+                       } else {
+                               pszBuffer--;
+                       }
+                       break;
+               // ANSI escape sequence
+               case '[':
+                       // Check if we have whole escape sequence in buffer.
+                       // This should not be isalpha anymore (Paul Brannan 9/1/98)
+                       pszChar = pszBuffer;
+                       while ((pszChar < pszBufferEnd) && (*pszChar <= '?'))
+                               pszChar++;
+                       if (pszChar == pszBufferEnd)
+                               pszBuffer -= 2;
+                       else
+                               pszBuffer = ParseEscapeANSI(pszBuffer, pszBufferEnd);
+                       break;
+#ifdef MTE_SUPPORT
+               case '~':
+                       // Frediano Ziglio, 5/31/2000
+                       // Meridian Terminal Emulator extension
+                       // !!! same as ANSI
+                       // !!! should put in MTE procedure
+                       pszChar = pszBuffer;
+                       while ((pszChar < pszBufferEnd) && (*pszChar <= '?'))
+                               pszChar++;
+                       if (pszChar == pszBufferEnd)
+                               pszBuffer -= 2;
+                       else
+                               pszBuffer = ParseEscapeMTE(pszBuffer, pszBufferEnd);
+                       break;
+#endif
+               default:
+#ifdef DEBUG
+                       Console.Beep();
+#endif
+                       break;
+       }
+
+       return pszBuffer;
+}
+
+// This function now only parses the ANSI buffer and does not do anything
+// with IAC sequences.  That code has been moved to TTelHndl.cpp.
+// The scroller update routines have been moved to TScroll.cpp.
+// (Paul Brannan 6/15/98)
+char* TANSIParser::ParseBuffer(char* pszHead, char* pszTail){
+       // copy into ANSI buffer
+       char * pszResult;
+       
+       // Parse the buffer for ANSI or display
+       while (pszHead < pszTail) {
+               if(!ini.get_output_redir()) {
+                       pszResult = ParseANSIBuffer(pszHead, pszTail);
+               } else {
+                       // Output is being redirected
+                       if(ini.get_strip_redir()) {
+                               // Skip the WriteFile() altogether and pass the buffer to a filter
+                               // Mark Miesfield 09/24/2000
+                               pszResult = PrintGoodChars(pszHead, pszTail);
+                       } else {
+                               DWORD Result;
+                               // Paul Brannan 7/29/98
+                               // Note that this has the unforunate effect of printing out
+                               // NULL (ascii 0) characters onto the screen
+                               if (!WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), pszHead,
+                                       pszTail - pszHead, &Result,     NULL)) pszResult = pszHead;
+                               pszResult = pszHead + Result;
+                       }
+               }
+               if (dumpfile)
+                       fwrite( pszHead, sizeof (char), pszResult-pszHead, dumpfile);
+               if(ini.get_scroll_enable()) Scroller.update(pszHead, pszResult);
+               if (pszResult == pszHead) break;
+               pszHead = pszResult;
+       }
+       // return the new head to the buffer
+       return pszHead;
+}
+
+// A simple routine to strip ANSI sequences
+// This isn't perfect, but it does an okay job (Paul Brannan 7/5/98)
+// Fixed a line counting bug (Paul Brannan 12/4/98)
+int TANSIParser::StripBuffer(char* pszHead, char* pszTail, int width) {
+       int lines = 0, c = 0;
+       char *pszBuf = pszHead;
+
+       while(pszHead < pszTail) {
+               if(iscntrl(*pszHead)) {
+                       switch(*(pszHead++)) {
+                       case 8:
+                       case 127:
+                               if(c>0) {
+                                       if(!(c%width)) lines--;
+                                       c--;
+                                       pszBuf--;
+                               }
+                               break;
+                       case 10: lines++;
+                       case 13:
+                               *(pszBuf++) = *(pszHead - 1);
+                               c = 0;
+                               break;
+                       case 27:
+                               switch(*(pszHead++)) {
+                               case 'Y': pszHead += 2; break;
+                               case '#':
+                               case '(':
+                               case ')':
+                               case '%': pszHead++; break;
+                               case '[':
+                                       while((pszHead < pszTail) && (*pszHead < '?'))
+                                               pszHead++;
+                                       pszHead++;
+                                       break;
+                               }
+                       }
+               } else {
+                       *(pszBuf++) = *(pszHead++);
+                       c++;
+               }
+               if(c != 0 && !(c%width))
+                       lines++;
+       }
+       
+       // Fill in the end of the buffer with blanks
+       while(pszBuf <= pszTail) *pszBuf++ = ' ';
+
+       return lines;
+}
+
+char* TANSIParser::ParseANSIBuffer(char* pszBuffer, char* pszBufferEnd)
+{
+       if(InPrintMode) {
+               return PrintBuffer(pszBuffer, pszBufferEnd);
+       }
+       
+       unsigned char tmpc = *(unsigned char *)pszBuffer;
+
+       if(tmpc == 27) {
+               return ParseEscape(pszBuffer, pszBufferEnd);
+       }
+       
+//     if((fast_write && tmpc < 32) ||
+//             !print_ctrl && (tmpc < 32 || (EightBit_Ansi &&
+//             (tmpc > 128 && tmpc < 128 + ' ')))) {
+
+       // We shouldn't print ctrl characters when fast write is enabled
+       // and ctrl chars are disabled (Paul Brannan 9/1/98)
+       if(tmpc < 32) {
+               // From the Linux kernel (Paul Brannan 12/5/98):
+               /* A bitmap for codes <32. A bit of 1 indicates that the code
+                * corresponding to that bit number invokes some special action
+                * (such as cursor movement) and should not be displayed as a
+                * glyph unless the disp_ctrl mode is explicitly enabled.
+                */
+               const long CTRL_ACTION = 0x0d00ff81;
+               const long CTRL_ALWAYS = 0x0800f501;
+               if(!(((print_ctrl?CTRL_ALWAYS:CTRL_ACTION)>>tmpc)&1)) {
+                       
+                       Console.WriteString((char *)&tmpc, 1);
+                       pszBuffer++;
+                       return pszBuffer;
+               }
+
+               switch (tmpc) {
+               case 0:
+                       pszBuffer++;
+                       break;
+               
+               // I.Ioannou 5/30/98
+               case 7:
+                       Console.Beep();
+                       pszBuffer++;
+                       break;
+               
+               // destructive backspace
+               case 8:
+                       // Added option for destructive backspace (Paul Brannan 5/13/98)
+                       // Changed to ConWriteCtrlString so that the cursor position can be
+                       // updated (Paul Brannan 5/25/98)
+                       if(ini.get_dstrbksp()) {
+                               Console.WriteCtrlChar('\b');
+                               Console.WriteString(" ", 1);
+                               Console.WriteCtrlChar('\b');
+                       }
+                       else Console.WriteCtrlChar('\b');
+                       pszBuffer++;
+                       break;
+               
+               // horizontal tab
+               case 9:
+                       {
+                               pszBuffer++;
+                               int x = Console.GetCursorX();
+                               if(x != -1)
+                                       Console.SetCursorPosition(tab_stops[x], Console.GetCursorY());
+                       }
+                       break;
+               
+               // Line Feed Char
+               case 10:
+                       // Test for local echo (Paul Brannan 8/25/98)
+                       if(Network.get_local_echo() || newline_mode) // &&
+                               Console.WriteCtrlChar('\x0d');
+                       Console.WriteCtrlChar('\x0a');
+                       pszBuffer++;
+                       break;
+               
+               // form feed
+               case 12:
+                       pszBuffer++;
+                       Console.ClearScreen();
+                       Console.SetRawCursorPosition(Console.GetCursorX(), 1); // changed fm 1
+                       break;
+               
+               case 13:
+                       Console.WriteCtrlChar('\x0d');
+                       pszBuffer++;
+
+                       break;
+
+               case 14:  // shift out of alternate chararcter set
+                       pszBuffer++;
+                       Charmap.setmap(map_G1); // Paul Brannan 6/25/98
+                       current_map = 1;
+                       break;
+       
+               case 15:  // shift in
+                       pszBuffer++;
+                       Charmap.setmap(map_G0); // Paul Brannan 6/25/98
+                       current_map = 0;
+                       break;
+               
+               // Paul Brannan 9/1/98 - Is this okay?
+               default:
+                       pszBuffer++;
+               }
+
+               return pszBuffer;
+       }
+
+       //  added by I.Ioannou 06 April, 1997
+       //  In 8 bit systems the server may send 0x9b instead of ESC[
+       //  Well, this will produce troubles in Greek 737 Code page
+       //  which uses 0x9b as the small "delta" - and I thing that there
+       //  is another European country with the same problem.
+       //  If we have to stay 8-bit clean we may have to
+       //  give the ability of ROM characters (ESC[11m),
+       //  for striped 8'th bit (ESC[12m) as SCO does,
+       //  or a parameter at compile (or run ?) time.
+       // We now check for a flag in the ini file (Paul Brannan 5/13/98)
+       // We also handle any 8-bit ESC sequence (Paul Brannan 6/28/98)
+       if(ini.get_eightbit_ansi() && (tmpc > 128 && tmpc < 128 + ' ')) {
+               // There's a chance the sequence might not parse.  If this happens
+               // then pszBuffer will be one character too far back, since
+               // ParseEscape is expecting two characters, not one.
+               // In that case we must handle it.
+               char *pszCurrent = pszBuffer;
+               pszBuffer = ParseEscape(pszBuffer, pszBufferEnd);
+               if(pszBuffer < pszCurrent) pszBuffer = pszCurrent;
+       }
+
+       char* pszCurrent = pszBuffer + 1;
+       // I.Ioannou 04 Sep 1997 FIXME with ESC[11m must show chars < 32
+       // Fixed (Paul Brannan 6/28/98)
+       while ((pszCurrent < pszBufferEnd) && (!iscntrl(*pszCurrent))) {
+               // I.Ioannou 04 Sep 1997 strip on high bit
+               if ( (inGraphMode) && (*pszCurrent > (char)32) )
+                       *pszCurrent |= 0x80 ;
+               pszCurrent++;
+       }
+       
+       // Note that this may break dumpfiles slightly.
+       // If 'B' is set to anything other than ASCII, this will cause problems
+       // (Paul Brannan 6/28/98)
+       if(current_map != 'B' && Charmap.enabled)
+               Charmap.translate_buffer(pszBuffer, pszCurrent);    
+       
+       last_char = *(pszCurrent-1);    // TITUS++: Remember last char
+
+       if(fast_write) {
+               pszBuffer += Console.WriteStringFast(pszBuffer,
+                       pszCurrent - pszBuffer);
+       } else {
+               pszBuffer += Console.WriteString(pszBuffer,
+                       pszCurrent - pszBuffer);
+       }
+
+       return pszBuffer;
+}
+
+// Added by I.Ioannou 06 April, 1997
+// Print the buffer until you reach ESC[4i
+char* TANSIParser::PrintBuffer(char* pszBuffer, char* pszBufferEnd) {
+       // Check if we have enough characters in buffer.
+       if ((pszBufferEnd - pszBuffer) < 4)
+               return pszBuffer;
+       char *tmpChar;
+       
+       tmpChar = pszBuffer;
+       if ( *tmpChar == 27 ) {
+               tmpChar++;
+               if ( *tmpChar == '[' ) {
+                       tmpChar++;
+                       if ( *tmpChar == '4' ) {
+                               tmpChar++;
+                               if ( *tmpChar == 'i' ) {
+                                       InPrintMode = 0; // Stop Print Log
+                                       if ( printfile != NULL )
+                                               fclose(printfile);
+                                       pszBuffer += 4;
+                                       return pszBuffer;
+                               }
+                       }
+               }
+       }
+       
+       if (printfile != NULL) {
+               fputc( *pszBuffer, printfile);
+               pszBuffer++;
+       } else
+               InPrintMode = 0;
+       
+       return pszBuffer;
+}
+
+/* - PrintGoodChars( pszHead, pszTail ) - - - - - - - - - - - - - - - - - - -
+-*
+
+  Mark Miesfield 09/24/2000
+
+  Prints the characters in a buffer, from the specified head to the specified
+  tail, to standard out, skipping any control characters or ANSI escape
+  sequences.
+
+  Parameters on entry:
+    pszHead  ->  Starting point in buffer.
+
+    pszTail  ->  Ending point in buffer.
+
+  Returns:
+    Pointer to the first character in the buffer that was not output to
+    standard out.  (Since no error checking is done, this is in effect
+    pszTail.)
+
+  Side Effects:
+    None.
+* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+*/
+char * TANSIParser::PrintGoodChars( char * pszHead, char * pszTail )  {
+
+  while ( pszHead < pszTail )  {
+    if ( iscntrl( *pszHead ) )  {
+      switch ( *(pszHead++) )  {
+        case 10 :
+          putc( 10, stdout );
+          break;
+
+        case 13 :
+          putc( 13, stdout );
+          break;
+
+        case 27:
+          switch ( *(pszHead++) )  {
+            case 'Y':
+              pszHead += 2;
+              break;
+
+            case '#':
+            case '(':
+            case ')':
+            case '%': pszHead++; break;
+            case '[':
+              while ( (pszHead < pszTail) && (*pszHead < '?') )
+                pszHead++;
+              pszHead++;
+              break;
+
+            default :
+              break;
+          }
+          break;
+
+        default :
+          break;
+      }
+    }
+    else
+      putc( *(pszHead++), stdout );
+  }
+  return ( pszTail );
+}
+// End of function:  PrintGoodChars( pszHead, pszTail )
diff --git a/rosapps/net/telnet/src/ansiprsr.h b/rosapps/net/telnet/src/ansiprsr.h
new file mode 100644 (file)
index 0000000..fd032c3
--- /dev/null
@@ -0,0 +1,85 @@
+#ifndef __ANSIPRSR_H
+#define __ANSIPRSR_H
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <string.h>
+#include "tnconfig.h"
+#include "tparser.h"
+
+// added this color table to make things go faster (Paul Branann 5/8/98)
+enum Colors {BLACK=0, BLUE, GREEN, CYAN, RED, MAGENTA, YELLOW, WHITE};
+static const int ANSIColors[] = {BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE};
+
+// This should be greater than the largest conceivable window size
+// 200 should suffice
+#define MAX_TAB_POSITIONS 200
+
+// Added by Frediano Ziglio 6/2/2000
+// Include Meridian Emulator support
+// undefine it to remove support
+#define MTE_SUPPORT 1
+
+// TANSIParser is now properly no longer a base class for TTelnetParser.
+// Screen output is handled in TConsole.cpp.
+// (Paul Brannan 6/15/98)
+class TANSIParser : public TParser {
+private:
+       char* ParseEscapeANSI(char* pszBuffer, char* pszBufferEnd);
+       char* ParseANSIBuffer(char* pszBuffer, char* pszBufferEnd);
+       char* ParseEscape(char* pszBuffer, char* pszBufferEnd);
+       // Added by I.Ioannou 06/04/97
+       char* PrintBuffer(char* pszBuffer, char* pszBufferEnd);
+       char* PrintGoodChars(char * pszHead, char * pszTail);
+
+#ifdef MTE_SUPPORT
+    // Added by Frediano Ziglio, 5/31/2000
+    char* ParseEscapeMTE(char* pszBuffer, char* pszBufferEnd);
+       short int mteRegionXF,mteRegionYF;
+#endif
+
+       void ConSetAttribute(unsigned char wAttr);
+       char *GetTerminalID();
+       void ConSetCursorPos(int x, int y);
+       void ResetTerminal();
+       void Init();
+
+       void SaveCurX(int iX);
+       void SaveCurY(int iY);
+
+       void resetTabStops();
+       
+       int iSavedCurX;
+       int iSavedCurY;
+       unsigned char iSavedAttributes;
+       FILE * dumpfile;
+
+       // Added by I.Ioannou 06 April 1997
+       FILE * printfile;
+       char InPrintMode;
+       int inGraphMode;
+
+       char last_char;                 // TITUS++: 2. November 98
+
+       char map_G0, map_G1;
+       int current_map;
+       bool vt52_mode;
+       bool print_ctrl;
+       bool ignore_margins;
+       bool fast_write;
+       bool newline_mode;
+
+       int tab_stops[MAX_TAB_POSITIONS];
+
+public:
+       // Changed by Paul Brannan 5/13/98
+       TANSIParser(TConsole &Console, KeyTranslator &RefKeyTrans,
+               TScroller &RefScroller, TNetwork &NetHandler, TCharmap &RefCharmap);
+       ~TANSIParser();
+       
+       char* ParseBuffer(char* pszBuffer, char* pszBufferEnd);
+       static int StripBuffer(char* pszBuffer, char* pszBufferEnd, int width);
+};
+
+#endif
\ No newline at end of file
diff --git a/rosapps/net/telnet/src/keytrans.cpp b/rosapps/net/telnet/src/keytrans.cpp
new file mode 100644 (file)
index 0000000..518b962
--- /dev/null
@@ -0,0 +1,227 @@
+///////////////////////////////////////////////////////////////////////////////
+//Telnet Win32 : an ANSI telnet client.
+//Copyright (C) 1998-2000 Paul Brannan
+//Copyright (C) 1998 I.Ioannou
+//Copyright (C) 1997 Brad Johnson
+//
+//This program is free software; you can redistribute it and/or
+//modify it under the terms of the GNU General Public License
+//as published by the Free Software Foundation; either version 2
+//of the License, or (at your option) any later version.
+//
+//This program is distributed in the hope that it will be useful,
+//but WITHOUT ANY WARRANTY; without even the implied warranty of
+//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//GNU General Public License for more details.
+//
+//You should have received a copy of the GNU General Public License
+//along with this program; if not, write to the Free Software
+//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+//I.Ioannou
+//roryt@hol.gr
+//
+///////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////
+//      Key translations - I.Ioannou (roryt@hol.gr)              //
+//          Athens - Greece    December 18, 1996 02:56am         //
+//          Reads a .cfg file and keeps the definitions          //
+//      modified for alternate keymap swiching                   //
+//          by Andrey V. Smilianets (smile@head.aval.kiev.ua)    //
+//          Kiev - Ukraine, December 1997.                       //
+//      modified to work with MSVC and the Standard Template     //
+//          library by Paul Brannan <pbranna@clemson.edu>,       //
+//          May 25, 1998                                         //
+//      updated June 7, 1998 by Paul Brannan to remove cout and  //
+//          cerr statements                                      //
+//      APP_KEY and APP2_Key added July 12, 1998 by Paul Brannan //
+///////////////////////////////////////////////////////////////////
+//                class KeyTranslator                            //
+//  Load          : loads or replaces the keymap                 //
+//  TranslateKey  : returns a char * to the key def              //
+//  AddKeyDef     : Changes or adds the key translation          //
+//  DeleteKeyDef  : Deletes a key def from the list              //
+///////////////////////////////////////////////////////////////////
+
+#include <windows.h>
+
+// changed to make work with VC++ (Paul Brannan 5/25/98)
+// FIX ME !!! Ioannou:  This must be __BORLANDC__ && VERSION < 5
+// but what is the directive for Borland version ????
+// FIXED Sept. 31, 2000 (Bernard Badger)
+//
+#if defined(__BORLANDC__) && (__BORLANDC < 0x0500)
+#include <mem.h>
+#else
+#include <memory.h>
+#endif
+
+#include "keytrans.h"
+#include "tnerror.h"
+
+/////////////////////////////////////////////////////////////
+//                class KeyTranslator                      //
+//  Load          : loads or replaces the keymap           //
+//  TranslateKey  : returns a sz to the key def            //
+//  AddKeyDef     : Changes or adds the key translation    //
+//  DeleteKeyDef  : Deletes a key def from the list        //
+/////////////////////////////////////////////////////////////
+
+
+KeyTranslator::KeyTranslator():
+mapArray(0,0,sizeof(KeyMap)),
+globals(0,0,sizeof(TKeyDef)) {
+       ext_mode = 0;                   // Paul Brannan 8/28/98
+       currentKeyMap = mainKeyMap = -1;
+};
+
+//AVS
+// perform keymap switching
+int KeyTranslator::switchMap(TKeyDef& tk) {
+    if ( mapArray.IsEmpty() ) {
+               return currentKeyMap = -1;
+    };
+    int i = mapArray.Find(KeyMap(tk));
+    if ( i != INT_MAX ) {
+               if (currentKeyMap == i)
+            currentKeyMap = mainKeyMap; // restore to default
+               else currentKeyMap = i;
+               return 1;
+    };
+    return 0;
+};
+
+// Let the calling function interpret the error code (Paul Brannan 12/17/98)
+int KeyTranslator::SwitchTo(int to) {
+       
+    int max = mapArray.GetItemsInContainer();
+    if (max == 0) return -1;
+    if (to < 0 || to > (max-1)) return 0;
+       
+    currentKeyMap = to;
+    return 1;
+};
+
+//AVS
+// rewrited to support multiple keymaps
+const char *KeyTranslator::TranslateKey(WORD wVirtualKeyCode,
+                                                                                         DWORD dwControlKeyState)
+{
+       if ( mapArray.IsEmpty() ) return NULL;
+       
+       TKeyDef ask(NULL, dwControlKeyState, wVirtualKeyCode);
+       
+       // if a keymap switch pressed
+       if ( switchMap(ask) > 0 ) return "";
+       
+       int i = mapArray[currentKeyMap].map.Find(ask);
+       
+       if ( i != INT_MAX) return mapArray[currentKeyMap].map[i].GetszKey();
+       
+       // if not found in current keymap
+       if ( currentKeyMap != mainKeyMap ) {
+               i = mapArray[mainKeyMap].map.Find(ask);
+               if ( i != INT_MAX)  return mapArray[mainKeyMap].map[i].GetszKey();
+       };
+       return NULL;
+};
+
+
+//AVS
+// rewrited to support multiple keymaps
+int KeyTranslator::AddKeyDef(WORD wVirtualKeyCode, DWORD dwControlKeyState,
+                             char*lpzKeyDef)
+{
+       if ( ! mapArray[currentKeyMap].map.IsEmpty() ) {
+               int i = mapArray[currentKeyMap].map.Find(TKeyDef(NULL, dwControlKeyState, wVirtualKeyCode));
+               if ( i != INT_MAX) {
+                       mapArray[currentKeyMap].map[i] = lpzKeyDef;
+                       return 1;
+               }
+       };
+       return mapArray[currentKeyMap].map.Add( TKeyDef(lpzKeyDef, dwControlKeyState, wVirtualKeyCode));
+}
+
+// Paul Brannan Feb. 22, 1999
+int KeyTranslator::AddKeyDef(WORD wVirtualKeyCode, DWORD dwControlKeyState,
+                             tn_ops the_op)
+{
+       optype op;
+       op.sendstr = 0;
+       op.the_op = the_op;
+       if ( ! mapArray[currentKeyMap].map.IsEmpty() ) {
+               int i = mapArray[currentKeyMap].map.Find(TKeyDef(NULL, dwControlKeyState, wVirtualKeyCode));
+               if ( i != INT_MAX) {
+                       mapArray[currentKeyMap].map[i] = op;
+                       return 1;
+               }
+       };
+       return mapArray[currentKeyMap].map.Add( TKeyDef(op, dwControlKeyState, wVirtualKeyCode));
+}
+
+// AVS
+int KeyTranslator::LookOnGlobal(char* vkey) {
+    if ( ! globals.IsEmpty() ) {
+               int max = globals.GetItemsInContainer();
+               for ( int i = 0; i < max ; i++ )
+                       if ( stricmp(globals[i].GetszKey(), vkey) == 0 )
+                               return i;
+    };
+    return INT_MAX;
+};
+
+int KeyTranslator::AddGlobalDef(WORD wVirtualKeyCode, char*lpzKeyDef) {
+       if ( ! globals.IsEmpty() ) {
+               int max = globals.GetItemsInContainer();
+               for ( int i = 0; i < max ; i++ ) {
+                       const char *s = globals[i].GetszKey();
+                       if ( stricmp(s, lpzKeyDef) == 0 ) {
+                               globals[i] = DWORD(wVirtualKeyCode);
+                               return 1;
+                       }
+               }
+       }
+       return globals.Add( TKeyDef(lpzKeyDef, 0, wVirtualKeyCode));
+}
+
+
+//AVS
+// rewrited to support multiple keymaps
+int KeyTranslator::DeleteKeyDef(WORD wVirtualKeyCode, DWORD dwControlKeyState)
+{
+       if ( mapArray.IsEmpty() || mapArray[currentKeyMap].map.IsEmpty() )
+               return 0;
+       
+       int i = mapArray[currentKeyMap].map.Find(TKeyDef(NULL, dwControlKeyState, wVirtualKeyCode));
+       
+       if ( i != INT_MAX) {
+               mapArray[currentKeyMap].map.Destroy(i);
+               return 1;
+       };
+       return 0;
+};
+
+//AVS
+// rewritten to support multiple keymaps
+void KeyTranslator::DeleteAllDefs(void)
+{
+       // This code wants to crash under the STL; Apparently the Destroy()
+       // function actually deletes the entry, rather than simply releasing
+       // memory.  I think flush() should do the same thing, at least the
+       // way it is written with STL_BIDS (Paul Brannan 5/25/98).
+       int max;
+       
+       max = mapArray.GetItemsInContainer();
+       if ( ! mapArray.IsEmpty() ) {
+               for ( int i = 0; i < max; i++ ) {
+                       if ( !mapArray[i].map.IsEmpty() ) {
+                               mapArray[i].map.Flush();
+                       };
+               };
+       };
+       globals.Flush();
+       mapArray.Flush();
+       currentKeyMap = -1;
+       mainKeyMap    = -1;
+};
diff --git a/rosapps/net/telnet/src/keytrans.h b/rosapps/net/telnet/src/keytrans.h
new file mode 100644 (file)
index 0000000..7f6a6ab
--- /dev/null
@@ -0,0 +1,97 @@
+///////////////////////////////////////////////////////////////////
+//                                                               //
+//                                                               //
+//      Key translations - I.Ioannou (roryt@hol.gr)              //
+//          Athens - Greece    December 18, 1996 02:56am         //
+//          Reads a .cfg file and keeps the key definitions      //
+//                for the WIN32 console telnet                   //
+//      modified for alternate keymap swiching                   //
+//          by Andrey V. Smilianets (smile@head.aval.kiev.ua)    //
+//          Kiev - Ukraine, December 1997.                       //
+///////////////////////////////////////////////////////////////////
+//                                                               //
+//                class KeyTranslator                            //
+//                                                               //
+//  Load          : loads or replaces the keymap                 //
+//  TranslateKey  : returns a char * to the key def              //
+//  AddKeyDef     : Changes or adds the key translation          //
+//  DeleteKeyDef  : Deletes a key def from the list              //
+///////////////////////////////////////////////////////////////////
+
+#ifndef __KEYTRANS_H
+#define __KEYTRANS_H
+
+#include "tkeydef.h"
+#include "tkeymap.h"
+
+#define TOKEN_DELIMITERS " +\t" // The word's delimiters
+
+// Ioannou 2 June 98:  Borland needs them - quick hack
+#ifdef __BORLANDC__
+#define bool BOOL
+#define true TRUE
+#define false FALSE
+#endif //  __BORLANDC__
+
+// Maybe not portable, but this is for application cursor mode
+// (Paul Brannan 5/27/98)
+// Updated for correct precedence in tncon.cpp (Paul Brannan 12/9/98)
+#define APP4_KEY                       0x8000
+#define APP3_KEY                       0x4000
+#define APP2_KEY                       0x2000
+#define APP_KEY                                0x1000
+
+/////////////////////////////////////////////////////////////
+//                class KeyTranslator                      //
+//  Load          : loads or replaces the keymap           //
+//  TranslateKey  : returns a sz to the key def            //
+//  AddKeyDef     : Changes or adds the key translation    //
+//  DeleteKeyDef  : Deletes a key def from the list        //
+/////////////////////////////////////////////////////////////
+
+class KeyTranslator {
+friend class TMapLoader;                       // FIX ME!!  This isn't the best solution
+public:
+    KeyTranslator();
+    ~KeyTranslator() { DeleteAllDefs(); }
+
+    int  SwitchTo(int);                                // switch to selected keymap
+       int switchMap(TKeyDef& tk);
+
+    // Returns a pointer to the string that should be printed.
+    // Should return NULL if there is no translation for the key.
+    const char *TranslateKey(WORD wVirtualKeyCode, DWORD dwControlKeyState);
+
+    // Changes or adds the key translation associated with
+    // wVirtualScanCode and dwControlKeyState.
+    // Return 1 on success.
+    int AddKeyDef(WORD wVirtualKeyCode, DWORD dwControlKeyState, char *lpzKeyDef);
+       int AddKeyDef(WORD wVirtualKeyCode, DWORD dwControlKeyState, tn_ops op);
+
+    // Delete a key translation
+       int DeleteKeyDef(WORD wVirtualKeyCode, DWORD dwControlKeyState);
+
+       // Paul Brannan 8/28/98
+       void set_ext_mode(DWORD mode) {ext_mode |= mode;}
+       void unset_ext_mode(DWORD mode) {ext_mode &= ~mode;}
+       void clear_ext_mode() {ext_mode = 0;}
+       DWORD get_ext_mode() {return ext_mode;}
+
+private:
+       DWORD     Fix_ControlKeyState(char *);
+       char*     Fix_Tok(char *);
+       DWORD ext_mode;                                                         // Paul Brannan 8/28/98
+
+       TArrayAsVector<KeyMap> mapArray;
+       TArrayAsVector<TKeyDef> globals;
+
+       void      DeleteAllDefs(void);
+       int       AddGlobalDef(WORD wVirtualKeyCode, char*lpzKeyDef);
+       int               LookOnGlobal(char* vkey);
+       DWORD     GetGlobalCode(int i) {return globals[i].GetCodeKey();}
+
+       int currentKeyMap, mainKeyMap;                          // AVS
+
+};
+       
+#endif // __KEYTRANS_H
\ No newline at end of file
diff --git a/rosapps/net/telnet/src/stl_bids.h b/rosapps/net/telnet/src/stl_bids.h
new file mode 100644 (file)
index 0000000..28d65b3
--- /dev/null
@@ -0,0 +1,169 @@
+// This is the STL wrapper for classlib/arrays.h from Borland's web site
+// It has been modified to be compatible with vc++ (Paul Branann 5/7/98)
+
+#ifndef STL_ARRAY_AS_VECTOR
+#define STL_ARRAY_AS_VECTOR
+
+#ifdef _MSC_VER
+#pragma warning(disable: 4786)
+#endif
+
+// #include <vector.h>
+// #include <algo.h>
+#include <vector>
+#include <algorithm>
+using namespace std;
+
+template <class T>
+class TArrayAsVector : public vector<T> {
+private:
+       const unsigned int growable;
+       const size_type lowerbound;
+public:
+       TArrayAsVector(size_type upper,
+               size_type lower = 0,
+               int delta = 0) :
+       vector<T>( ),
+               growable(delta),
+               lowerbound(lower)
+       { reserve(upper-lower + 1);}
+       
+       ~TArrayAsVector( )
+       { // This call is unnecessary?  (Paul Brannan 5/7/98)
+               // vector<T>::~vector( );
+       }
+       
+       int Add(const T& item)
+       { if(!growable && size( ) == capacity( ))
+       return 0;
+       else
+               insert(end( ), item);
+       return 1; }
+       
+       int AddAt(const T& item, size_type index)
+       { if(!growable &&
+       ((size( ) == capacity( )) ||
+       (ZeroBase(index > capacity( )) )))
+       return 0;
+       if(ZeroBase(index) > capacity( )) // out of bounds
+       { insert(end( ), 
+       ZeroBase(index) - size( ), T( ));
+       insert(end( ), item); }
+       else
+       { insert(begin( ) + ZeroBase(index), item); }
+       return 1;
+       }
+       
+       size_type ArraySize( )
+       { return capacity( ); }
+       
+       size_type BoundBase(size_type location) const
+       { if(location == UINT_MAX)
+       return INT_MAX;
+       else
+               return location + lowerbound; }
+       void Detach(size_type index)
+       { erase(begin( ) + ZeroBase(index)); }
+       
+       void Detach(const T& item)
+       { Destroy(Find(item)); }
+       
+       void Destroy(size_type index)
+       { erase(begin( ) + ZeroBase(index)); }
+       
+       void Destroy(const T& item)
+       { Destroy(Find(item)); }
+       
+       size_type Find(const T& item) const
+       { const_iterator location = find(begin( ), 
+       end( ), item);
+       if(location != end( ))
+               return BoundBase(size_type(location - 
+               begin( )));
+       else
+               return INT_MAX; }
+       
+       size_type GetItemsInContainer( )
+       { return size( ); }
+       
+       void Grow(size_type index)
+       { if( index < lowerbound )
+       Reallocate(ArraySize( ) + (index - 
+       lowerbound));
+       else if( index >= BoundBase(size( )))
+               Reallocate(ZeroBase(index) ); }
+       
+       int HasMember(const T& item)
+       { if(Find(item) != INT_MAX)
+       return 1;
+       else
+               return 0; }
+       
+       int IsEmpty( )
+       { return empty( ); }
+       
+       int IsFull( )
+       { if(growable)
+       return 0;
+       if(size( ) == capacity( ))
+               return 1;
+       else
+               return 0; }
+       
+       size_type LowerBound( )
+       { return lowerbound; }
+       
+       T& operator[] (size_type index)
+       { return vector<T>::
+       operator[](ZeroBase(index)); }
+       
+       const T& operator[] (size_type index) const
+       { return vector<T>::
+       operator[](ZeroBase(index)); }
+       
+       void Flush( )
+       {
+               // changed this to get it to work with VC++
+               // (Paul Brannan 5/7/98)
+#ifdef _MSC_VER
+               _Destroy(begin(), end());
+               _Last = _First;
+#else
+               destroy(begin( ), end( ));
+//#ifdef __CYGWIN__
+//             _M_finish = _M_start;
+//#else
+//             finish = start;
+//#endif
+#endif
+       }
+       
+       void Reallocate(size_type sz, 
+               size_type offset = 0)
+       { if(offset)
+       insert(begin( ), offset, T( ));
+       reserve(sz);
+       erase(end( ) - offset, end( )); }
+       
+       void RemoveEntry(size_type index)
+       { Detach(index); }
+       
+       void SetData(size_type index, const T& item)
+       { (*this)[index] = item; }
+       
+       size_type UpperBound( )
+       { return BoundBase(capacity( )) - 1; }
+       
+       size_type ZeroBase(size_type index) const
+       { return index - lowerbound; }
+       
+       // The assignment operator is not inherited (Paul Brannan 5/25/98)
+       TArrayAsVector& operator=(const TArrayAsVector& v) {
+               vector<T>::operator=(v);
+               // should growable and lowerbound be copied as well?
+               return *this;
+       }
+
+};
+
+#endif
\ No newline at end of file
diff --git a/rosapps/net/telnet/src/tcharmap.cpp b/rosapps/net/telnet/src/tcharmap.cpp
new file mode 100644 (file)
index 0000000..1a2525b
--- /dev/null
@@ -0,0 +1,220 @@
+///////////////////////////////////////////////////////////////////////////////
+//Telnet Win32 : an ANSI telnet client.
+//Copyright (C) 1998-2000 Paul Brannan
+//Copyright (C) 1998 I.Ioannou
+//Copyright (C) 1997 Brad Johnson
+//
+//This program is free software; you can redistribute it and/or
+//modify it under the terms of the GNU General Public License
+//as published by the Free Software Foundation; either version 2
+//of the License, or (at your option) any later version.
+//
+//This program is distributed in the hope that it will be useful,
+//but WITHOUT ANY WARRANTY; without even the implied warranty of
+//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//GNU General Public License for more details.
+//
+//You should have received a copy of the GNU General Public License
+//along with this program; if not, write to the Free Software
+//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+//I.Ioannou
+//roryt@hol.gr
+//
+///////////////////////////////////////////////////////////////////////////
+
+// TCharmap.cpp
+// A simple class for handling character maps
+// Written by Paul Brannan <pbranna@clemson.edu>
+// Last modified 7/12/98
+
+#include <string.h>
+#include "tcharmap.h"
+#include "tnconfig.h"
+
+// map B (US ASCII)
+// this maps each character to itself
+static char mapB[256] = {
+       (char)0x00,(char)0x01,(char)0x02,(char)0x03,(char)0x04,(char)0x05,(char)0x06,(char)0x07, // 0x00 - 0x0f
+       (char)0x08,(char)0x09,(char)0x0a,(char)0x0b,(char)0x0c,(char)0x0d,(char)0x0e,(char)0x0f,
+       (char)0x10,(char)0x11,(char)0x12,(char)0x13,(char)0x14,(char)0x15,(char)0x16,(char)0x17, // 0x10 - 0x1f
+       (char)0x18,(char)0x19,(char)0x1a,(char)0x1b,(char)0x1c,(char)0x1d,(char)0x1e,(char)0x1f,
+       (char)0x20,(char)0x21,(char)0x22,(char)0x23,(char)0x24,(char)0x25,(char)0x26,(char)0x27, // 0x20 - 0x2f
+       (char)0x28,(char)0x29,(char)0x2a,(char)0x2b,(char)0x2c,(char)0x2d,(char)0x2e,(char)0x2f,
+       (char)0x30,(char)0x31,(char)0x32,(char)0x33,(char)0x34,(char)0x35,(char)0x36,(char)0x37, // 0x30 - 0x3f
+       (char)0x38,(char)0x39,(char)0x3a,(char)0x3b,(char)0x3c,(char)0x3d,(char)0x3e,(char)0x3f,
+       (char)0x40,(char)0x41,(char)0x42,(char)0x43,(char)0x44,(char)0x45,(char)0x46,(char)0x47, // 0x40 - 0x4f
+       (char)0x48,(char)0x49,(char)0x4a,(char)0x4b,(char)0x4c,(char)0x4d,(char)0x4e,(char)0x4f,
+       (char)0x50,(char)0x51,(char)0x52,(char)0x53,(char)0x54,(char)0x55,(char)0x56,(char)0x57, // 0x50 - 0x5f
+       (char)0x58,(char)0x59,(char)0x5a,(char)0x5b,(char)0x5c,(char)0x5d,(char)0x5e,(char)0x5f,
+       (char)0x60,(char)0x61,(char)0x62,(char)0x63,(char)0x64,(char)0x65,(char)0x66,(char)0x67, // 0x60 - 0x6f
+       (char)0x68,(char)0x69,(char)0x6a,(char)0x6b,(char)0x6c,(char)0x6d,(char)0x6e,(char)0x6f,
+       (char)0x70,(char)0x71,(char)0x72,(char)0x73,(char)0x74,(char)0x75,(char)0x76,(char)0x77, // 0x70 - 0x7f
+       (char)0x78,(char)0x79,(char)0x7a,(char)0x7b,(char)0x7c,(char)0x7d,(char)0x7e,(char)0x7f,
+       (char)0x80,(char)0x81,(char)0x82,(char)0x83,(char)0x84,(char)0x85,(char)0x86,(char)0x87, // 0x80 - 0x8f
+       (char)0x88,(char)0x89,(char)0x8a,(char)0x8b,(char)0x8c,(char)0x8d,(char)0x8e,(char)0x8f,
+       (char)0x90,(char)0x91,(char)0x92,(char)0x93,(char)0x94,(char)0x95,(char)0x96,(char)0x97, // 0x90 - 0x9f
+       (char)0x98,(char)0x99,(char)0x9a,(char)0x9b,(char)0x9c,(char)0x9d,(char)0x9e,(char)0x9f,
+       (char)0xa0,(char)0xa1,(char)0xa2,(char)0xa3,(char)0xa4,(char)0xa5,(char)0xa6,(char)0xa7, // 0xa0 - 0xaf
+       (char)0xa8,(char)0xa9,(char)0xaa,(char)0xab,(char)0xac,(char)0xad,(char)0xae,(char)0xaf,
+       (char)0xb0,(char)0xb1,(char)0xb2,(char)0xb3,(char)0xb4,(char)0xb5,(char)0xb6,(char)0xb7, // 0xb0 - 0xbf
+       (char)0xb8,(char)0xb9,(char)0xba,(char)0xbb,(char)0xbc,(char)0xbd,(char)0xbe,(char)0xbf,
+       (char)0xc0,(char)0xc1,(char)0xc2,(char)0xc3,(char)0xc4,(char)0xc5,(char)0xc6,(char)0xc7, // 0xc0 - 0xcf
+       (char)0xc8,(char)0xc9,(char)0xca,(char)0xcb,(char)0xcc,(char)0xcd,(char)0xce,(char)0xcf,
+       (char)0xd0,(char)0xd1,(char)0xd2,(char)0xd3,(char)0xd4,(char)0xd5,(char)0xd6,(char)0xd7, // 0xd0 - 0xdf
+       (char)0xd8,(char)0xd9,(char)0xda,(char)0xdb,(char)0xdc,(char)0xdd,(char)0xde,(char)0xdf,
+       (char)0xe0,(char)0xe1,(char)0xe2,(char)0xe3,(char)0xe4,(char)0xe5,(char)0xe6,(char)0xe7, // 0xe0 - 0xef
+       (char)0xe8,(char)0xe9,(char)0xea,(char)0xeb,(char)0xec,(char)0xed,(char)0xee,(char)0xef,
+       (char)0xf0,(char)0xf1,(char)0xf2,(char)0xf3,(char)0xf4,(char)0xf5,(char)0xf6,(char)0xf7, // 0xf0 - 0xff
+       (char)0xf8,(char)0xf9,(char)0xfa,(char)0xfb,(char)0xfc,(char)0xfd,(char)0xfe,(char)0xff
+};
+
+// map A (UK/National)
+static char mapA[256] = {
+       (char)0x00,(char)0x01,(char)0x02,(char)0x03,(char)0x04,(char)0x05,(char)0x06,(char)0x07, // 0x00 - 0x0f
+       (char)0x08,(char)0x09,(char)0x0a,(char)0x0b,(char)0x0c,(char)0x0d,(char)0x0e,(char)0x0f,
+       (char)0x10,(char)0x11,(char)0x12,(char)0x13,(char)0x14,(char)0x15,(char)0x16,(char)0x17, // 0x10 - 0x1f
+       (char)0x18,(char)0x19,(char)0x1a,(char)0x1b,(char)0x1c,(char)0x1d,(char)0x1e,(char)0x1f,
+       (char)0x20,(char)0x21,(char)0x22,(char)0x9c,(char)0x24,(char)0x25,(char)0x26,(char)0x27, // 0x20 - 0x2f
+       (char)0x28,(char)0x29,(char)0x2a,(char)0x2b,(char)0x2c,(char)0x2d,(char)0x2e,(char)0x2f,
+       (char)0x30,(char)0x31,(char)0x32,(char)0x33,(char)0x34,(char)0x35,(char)0x36,(char)0x37, // 0x30 - 0x3f
+       (char)0x38,(char)0x39,(char)0x3a,(char)0x3b,(char)0x3c,(char)0x3d,(char)0x3e,(char)0x3f,
+       (char)0x40,(char)0x41,(char)0x42,(char)0x43,(char)0x44,(char)0x45,(char)0x46,(char)0x47, // 0x40 - 0x4f
+       (char)0x48,(char)0x49,(char)0x4a,(char)0x4b,(char)0x4c,(char)0x4d,(char)0x4e,(char)0x4f,
+       (char)0x50,(char)0x51,(char)0x52,(char)0x53,(char)0x54,(char)0x55,(char)0x56,(char)0x57, // 0x50 - 0x5f
+       (char)0x58,(char)0x59,(char)0x5a,(char)0x5b,(char)0x5c,(char)0x5d,(char)0x5e,(char)0x5f,
+       (char)0x60,(char)0x61,(char)0x62,(char)0x63,(char)0x64,(char)0x65,(char)0x66,(char)0x67, // 0x60 - 0x6f
+       (char)0x68,(char)0x69,(char)0x6a,(char)0x6b,(char)0x6c,(char)0x6d,(char)0x6e,(char)0x6f,
+       (char)0x70,(char)0x71,(char)0x72,(char)0x73,(char)0x74,(char)0x75,(char)0x76,(char)0x77, // 0x70 - 0x7f
+       (char)0x78,(char)0x79,(char)0x7a,(char)0x7b,(char)0x7c,(char)0x7d,(char)0x7e,(char)0x7f,
+       (char)0x80,(char)0x81,(char)0x82,(char)0x83,(char)0x84,(char)0x85,(char)0x86,(char)0x87, // 0x80 - 0x8f
+       (char)0x88,(char)0x89,(char)0x8a,(char)0x8b,(char)0x8c,(char)0x8d,(char)0x8e,(char)0x8f,
+       (char)0x90,(char)0x91,(char)0x92,(char)0x93,(char)0x94,(char)0x95,(char)0x96,(char)0x97, // 0x90 - 0x9f
+       (char)0x98,(char)0x99,(char)0x9a,(char)0x9b,(char)0x9c,(char)0x9d,(char)0x9e,(char)0x9f,
+       (char)0xa0,(char)0xa1,(char)0xa2,(char)0xa3,(char)0xa4,(char)0xa5,(char)0xa6,(char)0xa7, // 0xa0 - 0xaf
+       (char)0xa8,(char)0xa9,(char)0xaa,(char)0xab,(char)0xac,(char)0xad,(char)0xae,(char)0xaf,
+       (char)0xb0,(char)0xb1,(char)0xb2,(char)0xb3,(char)0xb4,(char)0xb5,(char)0xb6,(char)0xb7, // 0xb0 - 0xbf
+       (char)0xb8,(char)0xb9,(char)0xba,(char)0xbb,(char)0xbc,(char)0xbd,(char)0xbe,(char)0xbf,
+       (char)0xc0,(char)0xc1,(char)0xc2,(char)0xc3,(char)0xc4,(char)0xc5,(char)0xc6,(char)0xc7, // 0xc0 - 0xcf
+       (char)0xc8,(char)0xc9,(char)0xca,(char)0xcb,(char)0xcc,(char)0xcd,(char)0xce,(char)0xcf,
+       (char)0xd0,(char)0xd1,(char)0xd2,(char)0xd3,(char)0xd4,(char)0xd5,(char)0xd6,(char)0xd7, // 0xd0 - 0xdf
+       (char)0xd8,(char)0xd9,(char)0xda,(char)0xdb,(char)0xdc,(char)0xdd,(char)0xde,(char)0xdf,
+       (char)0xe0,(char)0xe1,(char)0xe2,(char)0xe3,(char)0xe4,(char)0xe5,(char)0xe6,(char)0xe7, // 0xe0 - 0xef
+       (char)0xe8,(char)0xe9,(char)0xea,(char)0xeb,(char)0xec,(char)0xed,(char)0xee,(char)0xef,
+       (char)0xf0,(char)0xf1,(char)0xf2,(char)0xf3,(char)0xf4,(char)0xf5,(char)0xf6,(char)0xf7, // 0xf0 - 0xff
+       (char)0xf8,(char)0xf9,(char)0xfa,(char)0xfb,(char)0xfc,(char)0xfd,(char)0xfe,(char)0xff
+};
+
+// map 0
+// Special graphics and line drawing
+static char map0[256] = {
+       (char)0x00,(char)0x01,(char)0x02,(char)0x03,(char)0x04,(char)0x05,(char)0x06,(char)0x07, // 0x00 - 0x0f
+       (char)0x08,(char)0x09,(char)0x0a,(char)0x0b,(char)0x0c,(char)0x0d,(char)0x0e,(char)0x0f,
+       (char)0x10,(char)0x11,(char)0x12,(char)0x13,(char)0x14,(char)0x15,(char)0x16,(char)0x17, // 0x10 - 0x1f
+       (char)0x18,(char)0x19,(char)0x1a,(char)0x1b,(char)0x1c,(char)0x1d,(char)0x1e,(char)0x1f,
+       (char)0x20,(char)0x21,(char)0x22,(char)0x23,(char)0x24,(char)0x25,(char)0x26,(char)0x27, // 0x20 - 0x2f
+       (char)0x28,(char)0x29,(char)0x2a,(char)0x2b,(char)0x2c,(char)0x2d,(char)0x2e,(char)0x2f,
+       (char)0x30,(char)0x31,(char)0x32,(char)0x33,(char)0x34,(char)0x35,(char)0x36,(char)0x37, // 0x30 - 0x3f
+       (char)0x38,(char)0x39,(char)0x3a,(char)0x3b,(char)0x3c,(char)0x3d,(char)0x3e,(char)0x3f,
+       (char)0x40,(char)0x41,(char)0x42,(char)0x43,(char)0x44,(char)0x45,(char)0x46,(char)0x47, // 0x40 - 0x4f
+       (char)0x48,(char)0x49,(char)0x4a,(char)0x4b,(char)0x4c,(char)0x4d,(char)0x4e,(char)0x4f,
+       (char)0x50,(char)0x51,(char)0x52,(char)0x53,(char)0x54,(char)0x55,(char)0x56,(char)0x57, // 0x50 - 0x5f
+       (char)0x58,(char)0x59,(char)0x5a,(char)0x5b,(char)0x04,(char)0x5d,(char)0x5e,(char)0xdb,
+       (char)0x04,(char)0xb1,(char)0x09,(char)0x0c,(char)0x0d,(char)0x0a,(char)0xf8,(char)0xf1, // 0x60 - 0x6f
+       (char)0x68,(char)0x0b,(char)0xd9,(char)0xbf,(char)0xda,(char)0xc0,(char)0xc5,(char)0xa9,
+       (char)0xa9,(char)0xc4,(char)0x5f,(char)0x5f,(char)0xc3,(char)0xb4,(char)0xc1,(char)0xc2, // 0x70 - 0x7f
+       (char)0xb3,(char)0xf3,(char)0xf2,(char)0xe3,(char)0x2f,(char)0x9c,(char)0xfe,(char)0x7f,
+       (char)0x80,(char)0x81,(char)0x82,(char)0x83,(char)0x84,(char)0x85,(char)0x86,(char)0x87, // 0x80 - 0x8f
+       (char)0x88,(char)0x89,(char)0x8a,(char)0x8b,(char)0x8c,(char)0x8d,(char)0x8e,(char)0x8f,
+       (char)0x90,(char)0x91,(char)0x92,(char)0x93,(char)0x94,(char)0x95,(char)0x96,(char)0x97, // 0x90 - 0x9f
+       (char)0x98,(char)0x99,(char)0x9a,(char)0x9b,(char)0x9c,(char)0x9d,(char)0x9e,(char)0x9f,
+       (char)0xa0,(char)0xa1,(char)0xa2,(char)0xa3,(char)0xa4,(char)0xa5,(char)0xa6,(char)0xa7, // 0xa0 - 0xaf
+       (char)0xa8,(char)0xa9,(char)0xaa,(char)0xab,(char)0xac,(char)0xad,(char)0xae,(char)0xaf,
+       (char)0xb0,(char)0xb1,(char)0xb2,(char)0xb3,(char)0xb4,(char)0xb5,(char)0xb6,(char)0xb7, // 0xb0 - 0xbf
+       (char)0xb8,(char)0xb9,(char)0xba,(char)0xbb,(char)0xbc,(char)0xbd,(char)0xbe,(char)0xbf,
+       (char)0xc0,(char)0xc1,(char)0xc2,(char)0xc3,(char)0xc4,(char)0xc5,(char)0xc6,(char)0xc7, // 0xc0 - 0xcf
+       (char)0xc8,(char)0xc9,(char)0xca,(char)0xcb,(char)0xcc,(char)0xcd,(char)0xce,(char)0xcf,
+       (char)0xd0,(char)0xd1,(char)0xd2,(char)0xd3,(char)0xd4,(char)0xd5,(char)0xd6,(char)0xd7, // 0xd0 - 0xdf
+       (char)0xd8,(char)0xd9,(char)0xda,(char)0xdb,(char)0xdc,(char)0xdd,(char)0xde,(char)0xdf,
+       (char)0xe0,(char)0xe1,(char)0xe2,(char)0xe3,(char)0xe4,(char)0xe5,(char)0xe6,(char)0xe7, // 0xe0 - 0xef
+       (char)0xe8,(char)0xe9,(char)0xea,(char)0xeb,(char)0xec,(char)0xed,(char)0xee,(char)0xef,
+       (char)0xf0,(char)0xf1,(char)0xf2,(char)0xf3,(char)0xf4,(char)0xf5,(char)0xf6,(char)0xf7, // 0xf0 - 0xff
+       (char)0xf8,(char)0xf9,(char)0xfa,(char)0xfb,(char)0xfc,(char)0xfd,(char)0xfe,(char)0xff
+};
+
+// map 0 (safe version for being unable to write ROM chars)
+// Special graphics and line drawing
+static char map0_safe[256] = {
+       (char)0x00,(char)0x01,(char)0x02,(char)0x03,(char)0x04,(char)0x05,(char)0x06,(char)0x07, // 0x00 - 0x0f
+       (char)0x08,(char)0x09,(char)0x0a,(char)0x0b,(char)0x0c,(char)0x0d,(char)0x0e,(char)0x0f,
+       (char)0x10,(char)0x11,(char)0x12,(char)0x13,(char)0x14,(char)0x15,(char)0x16,(char)0x17, // 0x10 - 0x1f
+       (char)0x18,(char)0x19,(char)0x1a,(char)0x1b,(char)0x1c,(char)0x1d,(char)0x1e,(char)0x1f,
+       (char)0x20,(char)0x21,(char)0x22,(char)0x23,(char)0x24,(char)0x25,(char)0x26,(char)0x27, // 0x20 - 0x2f
+       (char)0x28,(char)0x29,(char)0x2a,(char)0x2b,(char)0x2c,(char)0x2d,(char)0x2e,(char)0x2f,
+       (char)0x30,(char)0x31,(char)0x32,(char)0x33,(char)0x34,(char)0x35,(char)0x36,(char)0x37, // 0x30 - 0x3f
+       (char)0x38,(char)0x39,(char)0x3a,(char)0x3b,(char)0x3c,(char)0x3d,(char)0x3e,(char)0x3f,
+       (char)0x40,(char)0x41,(char)0x42,(char)0x43,(char)0x44,(char)0x45,(char)0x46,(char)0x47, // 0x40 - 0x4f
+       (char)0x48,(char)0x49,(char)0x4a,(char)0x4b,(char)0x4c,(char)0x4d,(char)0x4e,(char)0x4f,
+       (char)0x50,(char)0x51,(char)0x52,(char)0x53,(char)0x54,(char)0x55,(char)0x56,(char)0x57, // 0x50 - 0x5f
+       (char)0x58,(char)0x59,(char)0x5a,(char)0x5b,(char)0x04,(char)0x5d,(char)0x5e,(char)0xdb,
+       (char)0x04,(char)0xb1,(char)0xf8,(char)0xf9,(char)0xfb,(char)0xdb,(char)0xf8,(char)0xf1, // 0x60 - 0x6f
+       (char)0x68,(char)0xf9,(char)0xd9,(char)0xbf,(char)0xda,(char)0xc0,(char)0xc5,(char)0xa9,
+       (char)0xa9,(char)0xc4,(char)0x5f,(char)0x5f,(char)0xc3,(char)0xb4,(char)0xc1,(char)0xc2, // 0x70 - 0x7f
+       (char)0xb3,(char)0xf3,(char)0xf2,(char)0xe3,(char)0x2f,(char)0x9c,(char)0xfe,(char)0x7f,
+       (char)0x80,(char)0x81,(char)0x82,(char)0x83,(char)0x84,(char)0x85,(char)0x86,(char)0x87, // 0x80 - 0x8f
+       (char)0x88,(char)0x89,(char)0x8a,(char)0x8b,(char)0x8c,(char)0x8d,(char)0x8e,(char)0x8f,
+       (char)0x90,(char)0x91,(char)0x92,(char)0x93,(char)0x94,(char)0x95,(char)0x96,(char)0x97, // 0x90 - 0x9f
+       (char)0x98,(char)0x99,(char)0x9a,(char)0x9b,(char)0x9c,(char)0x9d,(char)0x9e,(char)0x9f,
+       (char)0xa0,(char)0xa1,(char)0xa2,(char)0xa3,(char)0xa4,(char)0xa5,(char)0xa6,(char)0xa7, // 0xa0 - 0xaf
+       (char)0xa8,(char)0xa9,(char)0xaa,(char)0xab,(char)0xac,(char)0xad,(char)0xae,(char)0xaf,
+       (char)0xb0,(char)0xb1,(char)0xb2,(char)0xb3,(char)0xb4,(char)0xb5,(char)0xb6,(char)0xb7, // 0xb0 - 0xbf
+       (char)0xb8,(char)0xb9,(char)0xba,(char)0xbb,(char)0xbc,(char)0xbd,(char)0xbe,(char)0xbf,
+       (char)0xc0,(char)0xc1,(char)0xc2,(char)0xc3,(char)0xc4,(char)0xc5,(char)0xc6,(char)0xc7, // 0xc0 - 0xcf
+       (char)0xc8,(char)0xc9,(char)0xca,(char)0xcb,(char)0xcc,(char)0xcd,(char)0xce,(char)0xcf,
+       (char)0xd0,(char)0xd1,(char)0xd2,(char)0xd3,(char)0xd4,(char)0xd5,(char)0xd6,(char)0xd7, // 0xd0 - 0xdf
+       (char)0xd8,(char)0xd9,(char)0xda,(char)0xdb,(char)0xdc,(char)0xdd,(char)0xde,(char)0xdf,
+       (char)0xe0,(char)0xe1,(char)0xe2,(char)0xe3,(char)0xe4,(char)0xe5,(char)0xe6,(char)0xe7, // 0xe0 - 0xef
+       (char)0xe8,(char)0xe9,(char)0xea,(char)0xeb,(char)0xec,(char)0xed,(char)0xee,(char)0xef,
+       (char)0xf0,(char)0xf1,(char)0xf2,(char)0xf3,(char)0xf4,(char)0xf5,(char)0xf6,(char)0xf7, // 0xf0 - 0xff
+       (char)0xf8,(char)0xf9,(char)0xfa,(char)0xfb,(char)0xfc,(char)0xfd,(char)0xfe,(char)0xff
+};
+
+TCharmap::TCharmap() {
+       memset(map, 0, sizeof(map));
+
+       map[0] = mapB;                          // default map
+       map['B'] = mapB;
+       map['A'] = mapA;
+       if(ini.get_fast_write()) {
+               map['0'] = map0_safe;
+               map['2'] = map0_safe;
+       } else {
+               map['0'] = map0;
+               map['2'] = map0;
+       }
+       current_map = map[0];
+}
+
+TCharmap::~TCharmap() {
+       for(int j = 0; j < 256; j++) {
+               if(map[j]) {
+                       // Don't delete static maps! 
+                       switch(j) {
+                               case 'B':
+                               case 'A':
+                               case '0':
+                               case '2':
+                               case 0: break;
+                               default: delete map[j];
+                       }
+               }
+       }
+}
+
+void TCharmap::modmap(char pos, char mapchar, char c) {
+       if(!map[mapchar]) {
+               map[mapchar] = new char[256];
+               for(int j = 0; j < 256; j++) map[mapchar][pos] = j;
+       }
+       map[mapchar][pos] = c;
+}
\ No newline at end of file
diff --git a/rosapps/net/telnet/src/tcharmap.h b/rosapps/net/telnet/src/tcharmap.h
new file mode 100644 (file)
index 0000000..0ad8b45
--- /dev/null
@@ -0,0 +1,41 @@
+// This is a simple class to handle character maps
+// (Paul Brannan 6/25/98)
+
+#ifndef __TCHARMAP_H
+#define __TCHARMAP_H
+
+class TCharmap {
+private:
+       char *map[256];
+       char *current_map;
+public:
+       TCharmap();
+       ~TCharmap();
+
+       void init() {}
+
+       char translate(char c, char mapchar) {
+               if(map[mapchar]) return map[mapchar][(unsigned char)c];
+               return c;
+       }
+       char translate(char c) {
+               return current_map[(unsigned char)c];
+       }
+
+       void setmap(char mapchar) {
+               if(map[mapchar]) current_map = map[mapchar];
+       }
+
+       void translate_buffer(char *start, char *end) {
+               while(start < end) {
+                       *start = translate(*start);
+                       start++;
+               }
+       }
+
+       void modmap(char pos, char mapchar, char c);
+
+       int enabled;
+};
+
+#endif
diff --git a/rosapps/net/telnet/src/tconsole.cpp b/rosapps/net/telnet/src/tconsole.cpp
new file mode 100644 (file)
index 0000000..e5e434f
--- /dev/null
@@ -0,0 +1,1008 @@
+///////////////////////////////////////////////////////////////////////////////
+//Telnet Win32 : an ANSI telnet client.
+//Copyright (C) 1998-2000 Paul Brannan
+//Copyright (C) 1998 I.Ioannou
+//Copyright (C) 1997 Brad Johnson
+//
+//This program is free software; you can redistribute it and/or
+//modify it under the terms of the GNU General Public License
+//as published by the Free Software Foundation; either version 2
+//of the License, or (at your option) any later version.
+//
+//This program is distributed in the hope that it will be useful,
+//but WITHOUT ANY WARRANTY; without even the implied warranty of
+//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//GNU General Public License for more details.
+//
+//You should have received a copy of the GNU General Public License
+//along with this program; if not, write to the Free Software
+//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+//I.Ioannou
+//roryt@hol.gr
+//
+///////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Module:             tconsole.cpp
+//
+// Contents:   screen functions
+//
+// Product:            telnet
+//
+//
+// Revisions: Mar. 29, 2000 pbranna@clemson (Paul Brannan)
+//            June 15, 1998 pbranna@clemson.edu
+//            May 16, 1998     pbranna@clemson.edu
+//            05. Sep.1997  roryt@hol.gr (I.Ioannou)
+//            11.May,1997   roryt@hol.gr
+//            06.April,1997 roryt@hol.gr
+//            30.M\84rz.1997  Titus_Boxberg@public.uni-hamburg.de
+//                   5.Dec.1996    jbj@nounname.com
+//            Version 2.0
+//            02.Apr.1995      igor.milavec@uni-lj.si
+//                                       Original code
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#include <windows.h>
+#include "tconsole.h"
+
+// argsused doesn't work on MSVC++
+#ifdef __BORLANDC__
+#pragma argsused
+#endif
+
+TConsole::TConsole(HANDLE h) {
+       hConsole = h;
+
+       GetConsoleScreenBufferInfo(hConsole, &ConsoleInfo);
+
+       // Start with correct colors
+       int fg = ini.get_normal_fg();
+       int bg = ini.get_normal_bg();
+       if(fg == -1)
+               fg = defaultfg = origfg = ConsoleInfo.wAttributes & 0xF;
+       else
+               defaultfg = origfg = fg;
+       if(bg == -1)
+               bg = defaultbg = origbg = (ConsoleInfo.wAttributes >> 4) & 0xF;
+       else
+               defaultbg = origbg = bg;
+       wAttributes = fg | (bg << 4);
+       reverse = blink = underline = false;
+       SetConsoleTextAttribute(hConsole, wAttributes);
+
+       insert_mode = 0;
+       
+       // Set the screen size
+       SetWindowSize(ini.get_term_width(), ini.get_term_height());
+
+       iScrollStart = -1;
+       iScrollEnd = -1;
+}
+
+TConsole::~TConsole() {
+       wAttributes = origfg | (origbg << 4);
+       SetCursorPosition(0, CON_HEIGHT);
+       SetConsoleTextAttribute(hConsole, wAttributes);
+       WriteCtrlChar('\x0a');
+}
+
+// Paul Brannan 8/2/98
+void TConsole::SetWindowSize(int width, int height) {
+       SMALL_RECT sr = {
+               CON_LEFT,
+               CON_TOP,
+               (width == -1) ? CON_RIGHT : CON_LEFT + width - 1,
+               (height == -1) ? CON_BOTTOM : CON_TOP + height - 1
+       };
+       ConsoleInfo.dwSize.X = width;
+       if(ConsoleInfo.dwSize.Y < height) ConsoleInfo.dwSize.Y = height;
+       SetConsoleScreenBufferSize(hConsole, ConsoleInfo.dwSize);
+       SetConsoleWindowInfo(hConsole, TRUE, &sr);
+       SetConsoleScreenBufferSize(hConsole, ConsoleInfo.dwSize);
+       sync();
+}
+
+// Paul Brannan 5/15/98
+void TConsole::sync() {
+       GetConsoleScreenBufferInfo(hConsole, &ConsoleInfo);
+}
+
+void TConsole::HighVideo() {
+       wAttributes = wAttributes | (unsigned char) 8;
+}
+
+void TConsole::LowVideo() {
+       wAttributes = wAttributes & (unsigned char) (0xff-8);
+}
+
+void TConsole::Normal() {
+       // I.Ioannou 11 May 1997
+       // Color 7 is correct on some systems (for example Linux)
+       // but not with others (for example SCO)
+       // we must preserve the colors :
+       // 06/04/98 thanks to Paul a .ini parameter from now on
+       
+       BlinkOff();
+       UnderlineOff();
+       if(ini.get_preserve_colors()) {
+               ReverseOff();
+               LowVideo();
+       } else {
+               fg = defaultfg;
+               bg = defaultbg;
+               wAttributes = (unsigned char)fg | (bg << 4);
+               reverse = false;
+       }
+}
+
+void TConsole::SetForeground(unsigned char wAttrib) {
+       if(reverse) bg = wAttrib; else fg = wAttrib;
+       wAttributes = (wAttributes & (unsigned char)0x88) | 
+               (unsigned char)fg | (bg << 4);
+}
+
+void TConsole::SetBackground(unsigned char wAttrib) {
+       if(reverse) fg = wAttrib; else bg = wAttrib;
+       wAttributes = (wAttributes & (unsigned char)0x88) | 
+               (unsigned char)fg | (bg << 4);
+}
+
+// As far as I can tell, there's no such thing as blink in Windows Console.
+// I tried using some inline asm to turn off high-intensity backgrounds,
+// but I got a BSOD.  Perhaps there is an undocumented function?
+// (Paul Brannan 6/27/98)
+void TConsole::BlinkOn() {
+       blink = 1;
+       if(underline) {
+               UlBlinkOn();
+       } else {
+               if(ini.get_blink_bg() != -1) {
+                       wAttributes &= 0x8f;                                    // turn off bg
+                       wAttributes |= ini.get_blink_bg() << 4;
+               }
+               if(ini.get_blink_fg() != -1) {
+                       wAttributes &= 0xf8;                                    // turn off fg
+                       wAttributes |= ini.get_blink_fg();
+               }
+               if(ini.get_blink_bg() == -1 && ini.get_blink_fg() == -1)
+                       wAttributes |= 0x80;
+       }
+}
+
+// Added by I.Ioannou 06 April, 1997
+void TConsole::BlinkOff() {
+       blink = 0;
+       if(underline) {
+               UlBlinkOff();
+       } else {
+               if(ini.get_blink_bg() != -1) {
+                       wAttributes &= 0x8f;                                    // turn off bg
+                       wAttributes |= defaultbg << 4;
+               }
+               if(ini.get_blink_fg() != -1) {
+                       wAttributes &= 0xf8;                                    // turn off fg
+                       wAttributes |= defaultfg;
+               }
+               if(ini.get_blink_bg() == -1 && ini.get_blink_fg() == -1)
+                       wAttributes &= 0x7f;
+       }
+}
+
+// Paul Brannan 6/27/98
+void TConsole::UnderlineOn() {
+       underline = 1;
+       if(blink) {
+               UlBlinkOn();
+       } else {
+               if(ini.get_underline_bg() != -1) {
+                       wAttributes &= 0x8f;                                    // turn off bg
+                       wAttributes |= ini.get_underline_bg() << 4;
+               }
+               if(ini.get_underline_fg() != -1) {
+                       wAttributes &= 0xf8;                                    // turn off fg
+                       wAttributes |= ini.get_underline_fg();
+               }
+               if(ini.get_underline_bg() == -1 && ini.get_underline_fg() == -1)
+                       wAttributes |= 0x80;
+       }
+}
+
+// Paul Brannan 6/27/98
+void TConsole::UnderlineOff() {
+       underline = 0;
+       if(blink) {
+               UlBlinkOff();
+       } else {
+               if(ini.get_blink_bg() != -1) {
+                       wAttributes &= 0x8f;                                    // turn off bg
+                       wAttributes |= defaultbg << 4;
+               }
+               if(ini.get_blink_fg() != -1) {
+                       wAttributes &= 0xf8;                                    // turn off fg
+                       wAttributes |= defaultfg;
+               }
+               if(ini.get_blink_bg() == -1 && ini.get_blink_fg() == -1)
+                       wAttributes &= 0x7f;
+       }
+}
+
+// Paul Brannan 6/27/98
+void TConsole::UlBlinkOn() {
+       if(ini.get_ulblink_bg() != -1) {
+               wAttributes &= 0x8f;                                    // turn off bg
+               wAttributes |= ini.get_ulblink_bg() << 4;
+       }
+       if(ini.get_ulblink_fg() != -1) {
+               wAttributes &= 0xf8;                                    // turn off fg
+               wAttributes |= ini.get_ulblink_fg();
+       }
+       if(ini.get_ulblink_bg() == -1 && ini.get_ulblink_fg() == -1)
+               wAttributes |= 0x80;
+}
+
+// Paul Brannan 6/27/98
+void TConsole::UlBlinkOff() {
+       if(blink) {
+               BlinkOn();
+       } else if(underline) {
+               UnderlineOn();
+       } else {
+               Normal();
+       }
+}
+
+// Paul Brannan 6/26/98
+void TConsole::Lightbg() {
+       WORD *pAttributes = new WORD[CON_COLS];
+       DWORD Result;
+
+       // Paul Brannan 8/5/98
+       // Correction: processing more than one line at a time causes a segfault
+       // if the screen width != 80
+       for(int i = CON_TOP; i <= CON_BOTTOM; i++) {
+               COORD Coord = {CON_LEFT, i};
+
+               ReadConsoleOutputAttribute(hConsole, pAttributes, (DWORD)(CON_COLS),
+                       Coord, &Result);
+       
+               for(DWORD j = 0; j < Result; j++) pAttributes[j] |= 0x80;
+
+               WriteConsoleOutputAttribute(hConsole, pAttributes, Result, Coord,
+                       &Result);
+       }
+
+       delete[] pAttributes; // clean up
+
+       wAttributes |= (unsigned char)0x80;
+       bg |= 8;
+}
+
+// Paul Brannan 6/26/98
+void TConsole::Darkbg() {
+       WORD *pAttributes = new WORD[CON_COLS];
+       DWORD Result;
+
+       // Paul Brannan 8/5/98
+       // Correction: processing more than one line at a time causes a segfault
+       // if the screen width != 80
+       for(int i = CON_TOP; i <= CON_BOTTOM; i++) {
+               COORD Coord = {CON_LEFT, i};
+
+               ReadConsoleOutputAttribute(hConsole, pAttributes, (DWORD)(CON_COLS),
+                       Coord, &Result);
+       
+               for(DWORD j = 0; j < Result; j++) pAttributes[j] &= 0x7f;
+
+               WriteConsoleOutputAttribute(hConsole, pAttributes, Result, Coord,
+                       &Result);
+       }
+
+       delete[] pAttributes; // clean up
+
+
+       wAttributes &= (unsigned char)0x7f;
+       bg &= 7;
+}
+
+// Added by I.Ioannou 11.May,1997
+void TConsole::ReverseOn() {
+       if (!reverse) {
+               reverse = true;
+
+               // atl  : forground attributes without the intensity
+               // ath  : backgound attributes without the blink
+               // bl   : the blink state
+               // ints : the intensity
+               unsigned char atl   = wAttributes & (unsigned char) 0x07;
+               unsigned char ath   = wAttributes & (unsigned char) 0x70;
+               unsigned char bl    = wAttributes & (unsigned char) 0x80;
+               unsigned char ints  = wAttributes & (unsigned char) 0x08;
+               wAttributes = bl | (atl << 4) | ints | (ath >> 4);
+       }
+}
+
+// Added by I.Ioannou 11.May,1997
+void TConsole::ReverseOff() {
+       if (reverse) {
+               reverse = false;
+               wAttributes = fg | (bg << 4);
+       }
+}
+
+unsigned long TConsole::WriteText(const char *pszString, unsigned long cbString) {
+       DWORD Result;
+
+       if(insert_mode) {
+               InsertCharacter(cbString);
+       }
+
+       WriteConsoleOutputCharacter(hConsole, (char *)pszString, cbString,
+               ConsoleInfo.dwCursorPosition, &Result);
+       FillConsoleOutputAttribute(hConsole, wAttributes, cbString,
+               ConsoleInfo.dwCursorPosition, &Result);
+       return Result;
+}
+
+// Formerly ConWriteString (Paul Brannan 6/28/98)
+unsigned long TConsole::WriteStringFast(const char* pszString, unsigned long cbString) {
+       DWORD Result;
+
+       SetConsoleTextAttribute(hConsole, wAttributes);
+
+       //check to see if the line is longer than the display
+       if (!getLineWrap() && ((unsigned)CON_CUR_X + cbString) >= (unsigned)CON_COLS) {
+               // Take care of the last line last colum exception...
+               // The display scrolls up if you use the normal char out
+               //   function even if you only write to the last place
+               //   on the line. :-(
+               if ((unsigned)CON_CUR_Y >= (unsigned)CON_HEIGHT) {
+                       unsigned long iFakeResult = cbString;
+                       cbString = CON_COLS - CON_CUR_X - 1;
+
+                       // FIX ME !!! This will avoid the exception when cbString
+                       // is <= 0 but still doesn't work :-(
+                       if (cbString > 0)
+                               WriteConsole(hConsole, pszString, cbString, &Result, 0);
+
+                       COORD dwBufferCoord;
+                       dwBufferCoord.X = 0;
+                       dwBufferCoord.Y = 0;
+
+                       CHAR_INFO ciBuffer;
+                       ciBuffer.Char.AsciiChar = *(pszString+cbString);
+                       ciBuffer.Attributes = wAttributes;
+                       SMALL_RECT srWriteRegion;
+                       srWriteRegion.Top =             (SHORT) CON_BOTTOM;
+                       srWriteRegion.Bottom =  (SHORT) CON_BOTTOM;
+                       srWriteRegion.Left =    (SHORT) CON_RIGHT;
+                       srWriteRegion.Right =   (SHORT) CON_RIGHT;
+
+                       COORD bufSize = {1,1};
+
+                       WriteConsoleOutput(hConsole, &ciBuffer, bufSize,
+                               dwBufferCoord, &srWriteRegion);
+
+                       // We need to update the ConsoleInfo struct now (Paul Brannan 5/9/98)
+                       ConsoleInfo.dwCursorPosition.X = CON_RIGHT;
+
+                       return iFakeResult; // Skip the chars that did not fit
+               }
+               // just write the line up to the end
+               else {
+                       int iFakeResult = cbString;
+                       cbString = CON_COLS - CON_CUR_X;
+
+                       if(cbString > 0) {
+                               WriteConsole(hConsole, pszString, cbString, &Result, 0);
+
+                               // We need to update the ConsoleInfo struct now (Paul Brannan 5/9/98)
+                               ConsoleInfo.dwCursorPosition.X += (unsigned short)Result;
+                       }
+
+                       return iFakeResult; // Skip the chars that did not fit
+               }
+       } else {
+               // If custom scrolling is enabled we must take care of it
+               if(iScrollStart != -1 || iScrollEnd != -1) {
+                       return WriteString(pszString, cbString);
+               }
+
+               // Apparently VT100 terminals have an invisible "81st" column that
+               // can hold a cursor until another character is printed.  I'm not sure
+               // exactly how to handle this, but here's a hack (Paul Brannan 5/28/98)
+               if(ini.get_vt100_mode() && cbString + (unsigned)CON_CUR_X == (unsigned)CON_COLS) {
+
+                       cbString--;
+                       if(cbString >= 0) WriteConsole(hConsole, pszString, cbString, &Result, 0);
+
+                       COORD dwBufferCoord;
+                       dwBufferCoord.X = 0;
+                       dwBufferCoord.Y = 0;
+
+                       CHAR_INFO ciBuffer;
+                       ciBuffer.Char.AsciiChar = *(pszString+cbString);
+                       ciBuffer.Attributes = wAttributes;
+                       SMALL_RECT srWriteRegion;
+                       srWriteRegion.Top =    (SHORT) ConsoleInfo.dwCursorPosition.Y;
+                       srWriteRegion.Bottom = (SHORT) ConsoleInfo.dwCursorPosition.Y;
+                       srWriteRegion.Left =   (SHORT) CON_RIGHT;
+                       srWriteRegion.Right =  (SHORT) CON_RIGHT;
+
+                       COORD bufSize = {1,1};
+
+                       WriteConsoleOutput(hConsole, &ciBuffer, bufSize,
+                               dwBufferCoord, &srWriteRegion);
+
+                       // Update the ConsoleInfo struct
+                       ConsoleInfo.dwCursorPosition.X = CON_RIGHT + 1;
+
+                       return Result + 1;
+               }
+
+               // normal line will wrap normally or not to the end of buffer
+               WriteConsole(hConsole, pszString, cbString, &Result, 0);
+
+               // We need to update the ConsoleInfo struct now (Paul Brannan 5/9/98)
+               // FIX ME!!! This is susceptible to the same problem as above.
+               // (e.g. we write out 160 characters)
+               ConsoleInfo.dwCursorPosition.X += (unsigned short)Result;
+               while(CON_CUR_X > CON_WIDTH) {
+                       ConsoleInfo.dwCursorPosition.X -= ConsoleInfo.dwSize.X;
+                       if((unsigned)CON_CUR_Y < (unsigned)CON_HEIGHT) {
+                               ConsoleInfo.dwCursorPosition.Y++;
+                       } else {
+                               // If we aren't at the bottom of the window, then we need to
+                               // scroll down (Paul Brannan 4/14/2000)
+                               if(ConsoleInfo.srWindow.Bottom < ConsoleInfo.dwSize.Y - 1) {
+                                       ConsoleInfo.srWindow.Top++;
+                                       ConsoleInfo.srWindow.Bottom++;
+                                       ConsoleInfo.dwCursorPosition.Y++;
+                                       SetConsoleWindowInfo(hConsole, TRUE, &ConsoleInfo.srWindow);
+                               }
+                       }
+               }
+       }
+
+       return Result;
+
+}
+
+unsigned long TConsole::WriteString(const char* pszString, unsigned long cbString) {
+       DWORD Result = 0;
+       
+       SetConsoleTextAttribute(hConsole, wAttributes);
+
+       //check to see if the line is longer than the display
+       if (!getLineWrap()){
+               unsigned long iFakeResult = cbString;
+               if((CON_CUR_X + cbString) >= (unsigned int)CON_COLS)
+                       cbString = CON_COLS - CON_CUR_X;
+               if(cbString > 0)
+                       Result = WriteText(pszString, cbString);
+
+               // We need to update the ConsoleInfo struct now (Paul Brannan 5/9/98)
+               ConsoleInfo.dwCursorPosition.X += (unsigned short)Result;
+               SetConsoleCursorPosition(hConsole, ConsoleInfo.dwCursorPosition);
+
+               return iFakeResult; // Skip the chars that did not fit
+       } else {
+               // Write up to the end of the line
+               unsigned long temp = cbString;
+               if((CON_CUR_X + temp) > (unsigned int)CON_COLS) {
+                       temp = CON_COLS - CON_CUR_X;
+               } else {
+                       Result = WriteText(pszString, temp);
+                       ConsoleInfo.dwCursorPosition.X += (unsigned short)Result;
+                       SetConsoleCursorPosition(hConsole, ConsoleInfo.dwCursorPosition);
+                       return Result;
+               }
+               if(temp > 0) {
+                       Result = WriteText(pszString, temp);
+                       ConsoleInfo.dwCursorPosition.X += (unsigned short)Result;
+                       temp = (unsigned short)Result;
+               }
+
+               // keep writing lines until we get to less than 80 chars left
+               while((temp + (unsigned int)CON_COLS) < cbString) {
+                       index(); // LF
+                       ConsoleInfo.dwCursorPosition.X = 0; // CR
+                       Result = WriteText(&pszString[temp], CON_COLS);
+                       temp += (unsigned short)Result;
+               }
+
+               // write out the last bit
+               if(temp < cbString) {
+                       index();
+                       ConsoleInfo.dwCursorPosition.X = 0;
+                       Result = WriteText(&pszString[temp], cbString - temp);
+                       temp += (unsigned short)Result;
+               }
+
+               // Apparently VT100 terminals have an invisible "81st" column that
+               // can hold a cursor until another character is printed.  I'm not sure
+               // exactly how to handle this, but here's a hack (Paul Brannan 5/28/98)
+               if(!ini.get_vt100_mode() && cbString + (unsigned)ConsoleInfo.dwCursorPosition.X
+                       == (unsigned int)CON_COLS) {
+                       index();
+                       ConsoleInfo.dwCursorPosition.X = 0;
+               }
+
+               SetConsoleCursorPosition(hConsole, ConsoleInfo.dwCursorPosition);
+
+               return temp;
+       }
+
+       return 0;
+}
+
+// This is for multi-character control strings (Paul Brannan 6/26/98)
+unsigned long TConsole::WriteCtrlString(const char *pszString, unsigned long cbString) {
+       unsigned long total = 0;
+       while(total < cbString) {
+               unsigned long Result = WriteCtrlChar(*(pszString + total));
+               if(Result == 0) {
+                       Result = WriteStringFast(pszString + total, 1);
+                       if(Result == 0) return total;
+               }
+               total += Result;
+       }
+       return total;
+}
+
+// This is for printing single control characters
+// WriteCtrlString uses this (Paul Brannan 6/26/98)
+unsigned long TConsole::WriteCtrlChar(char c) {
+       // The console does not handel the CR/LF chars as we might expect
+       // when using color. The attributes are not set correctly, so we
+       // must interpret them manualy to preserve the colors on the screen.
+       
+       unsigned long Result = 0; // just in case (Paul Brannan 6/26/98)
+       switch (c) {
+    case '\x09': // horizontal tab
+               SetCursorPosition((((CON_CUR_X/8)+1)*8), CON_CUR_Y);
+               Result = 1;
+               break;
+               
+    case '\x0a': // line feed
+               index();
+               Result = 1;
+               break;
+    case '\x0d': // carrage return
+               SetCursorPosition(CON_LEFT, CON_CUR_Y); // move to beginning of line
+               Result = 1;
+               break;
+       case '\b': // backspace
+               // Added support for backspace so the cursor position can be changed
+               // (Paul Brannan 5/25/98)
+               MoveCursorPosition(-1, 0);
+               Result = 1;
+    default :    // else just write it like normal
+               break;
+       }
+       
+       return Result;
+}
+
+void TConsole::index() {
+       // if on the last line scroll up
+       // This must work with scrolling (Paul Brannan 5/13/98)
+       if(iScrollEnd != -1 && (signed)CON_CUR_Y >= iScrollEnd) {
+               ScrollDown(iScrollStart, iScrollEnd, -1);
+       } else if ((iScrollEnd == -1 && (signed)CON_CUR_Y >= (signed)CON_HEIGHT)) {
+               DWORD Result;
+               WriteConsole(hConsole, "\n", 1, &Result, NULL);
+               
+               // If we aren't at the bottom of the buffer, then we need to
+               // scroll down (Paul Brannan 4/14/2000)
+               if(iScrollEnd == -1 && ConsoleInfo.srWindow.Bottom < ConsoleInfo.dwSize.Y - 1) {
+                       ConsoleInfo.srWindow.Top++;
+                       ConsoleInfo.srWindow.Bottom++;
+                       ConsoleInfo.dwCursorPosition.Y++;
+                       // SetConsoleWindowInfo(hConsole, TRUE, &ConsoleInfo.srWindow);
+               } else {
+                       ClearLine();
+               }
+       } else {     // else move cursor down to the next line
+               SetCursorPosition(CON_CUR_X, CON_CUR_Y + 1);
+       }
+}
+
+void TConsole::reverse_index() {
+       // if on the top line scroll down
+       // This must work with scrolling (Paul Brannan 5/13/98)
+       // We should be comparing against iScrollStart, not iScrollEnd (PB 12/2/98)
+       if (iScrollStart == -1 && (signed)CON_CUR_Y <= 0) {
+               ScrollDown(iScrollStart, -1, 1);
+       } else if (iScrollStart != -1 && (signed)CON_CUR_Y <= iScrollStart) {
+                       ScrollDown(iScrollStart, iScrollEnd, 1);
+       } else       // else move cursor up to the previous line
+               SetCursorPosition(CON_CUR_X,CON_CUR_Y - 1);
+}
+
+void TConsole::ScrollDown( int iStartRow , int iEndRow, int bUp ){
+       CHAR_INFO ciChar;
+       SMALL_RECT srScrollWindow;
+       
+       // Correction from I.Ioannou 11 May 1997
+       // check the scroll region
+       if (iStartRow < iScrollStart) iStartRow = iScrollStart;
+       
+       // Correction from I.Ioannou 11 May 1997
+       // this will make Top the CON_TOP
+       if ( iStartRow == -1) iStartRow = 0;
+
+       // Correction from I.Ioannou 18 Aug 97
+       if ( iEndRow == -1)     {
+               if ( iScrollEnd == -1 )
+                       iEndRow = CON_HEIGHT;
+               else
+                       iEndRow = ((CON_HEIGHT <= iScrollEnd) ? CON_HEIGHT : iScrollEnd);
+       }
+       //
+
+       if ( iStartRow > CON_HEIGHT) iStartRow = CON_HEIGHT;
+       if ( iEndRow > CON_HEIGHT) iEndRow = CON_HEIGHT;
+       
+       srScrollWindow.Left =           (CON_LEFT);
+       srScrollWindow.Right =  (SHORT) (CON_RIGHT);
+       srScrollWindow.Top =    (SHORT) (CON_TOP + iStartRow );
+       srScrollWindow.Bottom = (SHORT) (CON_TOP + iEndRow); // don't subtract 1 (PB 5/28)
+
+       ciChar.Char.AsciiChar = ' ';           // fill with spaces
+       ciChar.Attributes = wAttributes;       // fill with current attrib
+       
+       // This should speed things up (Paul Brannan 9/2/98)
+       COORD dwDestOrg = {srScrollWindow.Left, srScrollWindow.Top + bUp};
+       
+       // Note that iEndRow and iStartRow had better not be equal to -1 at this
+       // point.  There are four cases to consider for out of bounds.  Two of
+       // these cause the scroll window to be cleared; the others cause the
+       // scroll region to be modified.  (Paul Brannan 12/3/98)
+       if(dwDestOrg.Y > CON_TOP + iEndRow) {
+               // We are scrolling past the end of the scroll region, so just
+               // clear the window instead (Paul Brannan 12/3/98)
+               ClearWindow(CON_TOP + iStartRow, CON_TOP + iEndRow);
+               return;
+       } else if(dwDestOrg.Y + (iEndRow-iStartRow+1) < CON_TOP + iStartRow) {
+               // We are scrolling past the end of the scroll region, so just
+               // clear the window instead (Paul Brannan 12/3/98)
+               ClearWindow(CON_TOP + iStartRow, CON_TOP + iEndRow);
+               return;
+       } else if(dwDestOrg.Y < CON_TOP + iStartRow) {
+               // Modify the scroll region (Paul Brannan 12/3/98)
+               dwDestOrg.Y = CON_TOP + iStartRow;
+               srScrollWindow.Top -= bUp;
+       } else  if(dwDestOrg.Y + (iEndRow-iStartRow+1) > CON_TOP + iEndRow) {
+               // Modify the scroll region (Paul Brannan 12/3/98)
+               srScrollWindow.Bottom -= bUp;
+       }
+       
+       ScrollConsoleScreenBuffer(hConsole, &srScrollWindow,
+               0, dwDestOrg, &ciChar);
+}
+
+// This allows us to clear the screen with an arbitrary character
+// (Paul Brannan 6/26/98)
+void TConsole::ClearScreen(char c) {
+       DWORD dwWritten;
+       COORD Coord = {CON_LEFT, CON_TOP};
+       FillConsoleOutputCharacter(hConsole, c, (DWORD)(CON_COLS)*
+               (DWORD)(CON_LINES), Coord, &dwWritten);
+       FillConsoleOutputAttribute(hConsole, wAttributes, (DWORD)(CON_COLS)*
+               (DWORD)(CON_LINES), Coord, &dwWritten);
+}
+
+// Same as clear screen, but only affects the scroll region
+void TConsole::ClearWindow(int iStartRow, int iEndRow, char c) {
+       DWORD dwWritten;
+       COORD Coord = {CON_LEFT, CON_TOP + iStartRow};
+       FillConsoleOutputCharacter(hConsole, c, (DWORD)(CON_COLS)*
+               (DWORD)(iEndRow-iStartRow+1), Coord, &dwWritten);
+       FillConsoleOutputAttribute(hConsole, wAttributes, (DWORD)(CON_COLS)*
+               (DWORD)(CON_LINES), Coord, &dwWritten);
+}
+
+// Clear from cursor to end of screen
+void TConsole::ClearEOScreen(char c)
+{
+       DWORD dwWritten;
+       COORD Coord = {CON_LEFT, CON_TOP + CON_CUR_Y + 1};
+       FillConsoleOutputCharacter(hConsole, c, (DWORD)(CON_COLS)*
+               (DWORD)(CON_HEIGHT - CON_CUR_Y), Coord, &dwWritten);
+       FillConsoleOutputAttribute(hConsole, wAttributes, (DWORD)(CON_COLS)*
+               (DWORD)(CON_LINES - CON_CUR_Y), Coord, &dwWritten);
+       ClearEOLine();
+}
+
+// Clear from beginning of screen to cursor
+void TConsole::ClearBOScreen(char c)
+{
+       DWORD dwWritten;
+       COORD Coord = {CON_LEFT, CON_TOP};
+       FillConsoleOutputCharacter(hConsole, c, (DWORD)(CON_COLS)*
+               (DWORD)(CON_CUR_Y), Coord, &dwWritten);
+       FillConsoleOutputAttribute(hConsole, wAttributes, (DWORD)(CON_COLS)*
+               (DWORD)(CON_CUR_Y), Coord, &dwWritten);
+       ClearBOLine();
+}
+
+void TConsole::ClearLine(char c)
+{
+       DWORD dwWritten;
+       COORD Coord = {CON_LEFT, CON_TOP + CON_CUR_Y};
+       FillConsoleOutputCharacter(hConsole, c, (DWORD)(CON_COLS),
+               Coord, &dwWritten);
+       FillConsoleOutputAttribute(hConsole, wAttributes, (DWORD)(CON_COLS),
+               Coord, &dwWritten);
+       GetConsoleScreenBufferInfo(hConsole, &ConsoleInfo);
+}
+
+void TConsole::ClearEOLine(char c)
+{
+       DWORD dwWritten;
+       COORD Coord = {CON_LEFT + CON_CUR_X, CON_TOP + CON_CUR_Y};
+       FillConsoleOutputAttribute(hConsole, wAttributes,
+               (DWORD)(CON_RIGHT - CON_CUR_X) +1, Coord, &dwWritten);
+       FillConsoleOutputCharacter(hConsole, c, (DWORD)(CON_RIGHT - CON_CUR_X) +1,
+               Coord, &dwWritten);
+       GetConsoleScreenBufferInfo(hConsole, &ConsoleInfo);
+}
+
+void TConsole::ClearBOLine(char c)
+{
+       DWORD dwWritten;
+       COORD Coord = {CON_LEFT, CON_TOP + CON_CUR_Y};
+       FillConsoleOutputCharacter(hConsole, c, (DWORD)(CON_CUR_X) + 1, Coord,
+               &dwWritten);
+       FillConsoleOutputAttribute(hConsole, wAttributes, (DWORD)(CON_CUR_X) + 1,
+               Coord, &dwWritten);
+       GetConsoleScreenBufferInfo(hConsole, &ConsoleInfo);
+}
+
+
+//     Inserts blank lines to the cursor-y-position
+//     scrolls down the rest. CURSOR MOVEMENT (to Col#1) ???
+void TConsole::InsertLine(int numlines)
+{
+       COORD           to;
+       SMALL_RECT      from;
+       SMALL_RECT      clip;
+       CHAR_INFO               fill;
+       int             acty;
+       
+       // Rest of screen would be deleted
+       if ( (acty = GetCursorY()) >= CON_LINES - numlines ) {
+               ClearEOScreen();    // delete rest of screen
+               return;
+       } /* IF */
+       
+       //      Else scroll down the part of the screen which is below the
+       //      cursor.
+       from.Left =             CON_LEFT;
+       from.Top =              CON_TOP + (SHORT)acty;
+       from.Right =    CON_LEFT + (SHORT)CON_COLS;
+       from.Bottom =   CON_TOP + (SHORT)CON_LINES;
+       
+       clip = from;
+       to.X = 0;
+       to.Y = (SHORT)(from.Top + numlines);
+       
+       fill.Char.AsciiChar = ' ';
+       fill.Attributes = 7;            // WHICH ATTRIBUTES TO TAKE FOR BLANK LINE ??
+       
+       ScrollConsoleScreenBuffer(hConsole, &from, &clip, to, &fill);
+} /* InsertLine */
+
+//     Inserts blank characters under the cursor
+void TConsole::InsertCharacter(int numchar)
+{
+       int             actx;
+       SMALL_RECT      from;
+       SMALL_RECT      clip;
+       COORD                   to;
+       CHAR_INFO               fill;
+       
+       if ( (actx = GetCursorX()) >= CON_COLS - numchar ) {
+               ClearEOLine();
+               return;
+       } /* IF */
+       
+       from.Left =             CON_LEFT + (SHORT)actx;
+       from.Top =              CON_TOP + (SHORT)GetCursorY();
+       from.Right =    CON_LEFT + (SHORT)CON_COLS;
+       from.Bottom =   CON_TOP + (SHORT)from.Top;
+       
+       clip = from;
+       to.X = (SHORT)(actx + numchar);
+       to.Y = from.Top;
+       
+       fill.Char.AsciiChar = ' ';
+       fill.Attributes = wAttributes; // WHICH ATTRIBUTES TO TAKE FOR BLANK CHAR ??
+       
+       ScrollConsoleScreenBuffer(hConsole, &from, &clip, to, &fill);
+} /* InsertCharacter */
+
+// Deletes characters under the cursor
+// Note that there are cases in which all the following lines should shift by
+// a character, but we don't handle these.  This could break some
+// VT102-applications, but it shouldn't be too much of an issue.
+void TConsole::DeleteCharacter(int numchar)
+{
+       int             actx;
+       SMALL_RECT      from;
+       SMALL_RECT      clip;
+       COORD                   to;
+       CHAR_INFO               fill;
+       
+       if ( (actx = GetCursorX()) >= CON_COLS - numchar ) {
+               ClearEOLine();
+               return;
+       } /* IF */
+       
+       from.Left =             CON_LEFT + (SHORT)actx;
+       from.Top =              CON_TOP + (SHORT)GetCursorY();
+       from.Right =    CON_LEFT + (SHORT)CON_COLS;
+       from.Bottom =   CON_TOP + from.Top;
+       
+       clip = from;
+       to.X = (SHORT)(actx - numchar);
+       to.Y = from.Top;
+       
+       fill.Char.AsciiChar = ' ';
+       fill.Attributes = wAttributes; // WHICH ATTRIBUTES TO TAKE FOR BLANK CHAR ??
+       
+       ScrollConsoleScreenBuffer(hConsole, &from, &clip, to, &fill);
+} /* DeleteCharacter */
+
+void TConsole::SetRawCursorPosition(int x, int y) {
+       if (x > CON_WIDTH)  x = CON_WIDTH;
+       if (x < 0)                      x = 0;
+       if (y > CON_HEIGHT)     y = CON_HEIGHT;
+       if (y < 0)                      y = 0;
+       COORD Coord = {(short)(CON_LEFT + x), (short)(CON_TOP + y)};
+       SetConsoleCursorPosition(hConsole, Coord);
+       
+       // Update the ConsoleInfo struct (Paul Brannan 5/9/98)
+       ConsoleInfo.dwCursorPosition.Y = Coord.Y;
+       ConsoleInfo.dwCursorPosition.X = Coord.X;
+       
+       // bug fix in case we went too far (Paul Brannan 5/25/98)
+       if(ConsoleInfo.dwCursorPosition.X < CON_LEFT)
+               ConsoleInfo.dwCursorPosition.X = CON_LEFT;
+       if(ConsoleInfo.dwCursorPosition.X > CON_RIGHT)
+               ConsoleInfo.dwCursorPosition.X = CON_RIGHT;
+       if(ConsoleInfo.dwCursorPosition.Y < CON_TOP)
+               ConsoleInfo.dwCursorPosition.Y = CON_TOP;
+       if(ConsoleInfo.dwCursorPosition.Y > CON_BOTTOM)
+               ConsoleInfo.dwCursorPosition.Y = CON_BOTTOM;
+}
+
+// The new SetCursorPosition takes scroll regions into consideration
+// (Paul Brannan 6/27/98)
+void TConsole::SetCursorPosition(int x, int y) {
+       if (x > CON_WIDTH)  x = CON_WIDTH;
+       if (x < 0)                      x = 0;
+       if(iScrollEnd != -1) {
+               if(y > iScrollEnd)              y = iScrollEnd;
+       } else {
+               if(y > CON_HEIGHT)              y = CON_HEIGHT;
+       }
+       if(iScrollStart != -1) {
+               if(y < iScrollStart)    y = iScrollStart;
+       } else {
+               if(y < 0)                               y = 0;
+       }
+
+       COORD Coord = {(short)(CON_LEFT + x), (short)(CON_TOP + y)};
+       SetConsoleCursorPosition(hConsole, Coord);
+       
+       // Update the ConsoleInfo struct
+       ConsoleInfo.dwCursorPosition.Y = Coord.Y;
+       ConsoleInfo.dwCursorPosition.X = Coord.X;
+}
+
+void TConsole::MoveCursorPosition(int x, int y) {
+       SetCursorPosition(CON_CUR_X + x, CON_CUR_Y + y);
+}
+
+void TConsole::SetExtendedMode(int iFunction, BOOL bEnable)
+{
+       // Probably should do something here...
+       // Should change the screen mode, but do we need this?
+}
+
+void TConsole::SetScroll(int start, int end) {
+       iScrollStart = start;
+       iScrollEnd = end;
+}
+
+void TConsole::Beep() {
+       if(ini.get_do_beep()) {
+               if(!ini.get_speaker_beep()) printit("\a");
+               else ::Beep(400, 100);
+       }
+}
+
+void TConsole::SetCursorSize(int pct) {
+       CONSOLE_CURSOR_INFO ci = {(pct != 0)?pct:1, pct != 0};
+       SetConsoleCursorInfo(hConsole, &ci);
+}
+
+void saveScreen(CHAR_INFO *chiBuffer) {
+       HANDLE hStdout;
+       CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo;
+       SMALL_RECT srctReadRect;
+       COORD coordBufSize;
+       COORD coordBufCoord;
+       
+       hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
+       GetConsoleScreenBufferInfo(hStdout, &ConsoleInfo);
+       
+    srctReadRect.Top = CON_TOP;    /* top left: row 0, col 0  */
+    srctReadRect.Left = CON_LEFT;
+    srctReadRect.Bottom = CON_BOTTOM; /* bot. right: row 1, col 79 */
+    srctReadRect.Right = CON_RIGHT;
+       
+    coordBufSize.Y = CON_BOTTOM-CON_TOP+1;
+    coordBufSize.X = CON_RIGHT-CON_LEFT+1;
+       
+    coordBufCoord.X = CON_TOP;
+    coordBufCoord.Y = CON_LEFT;
+       
+    ReadConsoleOutput(
+               hStdout,        /* screen buffer to read from       */
+               chiBuffer,      /* buffer to copy into              */
+               coordBufSize,   /* col-row size of chiBuffer        */
+               
+               coordBufCoord,  /* top left dest. cell in chiBuffer */
+               &srctReadRect); /* screen buffer source rectangle   */
+}
+
+void restoreScreen(CHAR_INFO *chiBuffer) {
+       HANDLE hStdout;
+       CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo;
+       SMALL_RECT srctReadRect;
+       COORD coordBufSize;
+       COORD coordBufCoord;
+       
+       hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
+       GetConsoleScreenBufferInfo(hStdout, &ConsoleInfo);
+       
+       // restore screen
+    srctReadRect.Top = CON_TOP;    /* top left: row 0, col 0  */
+    srctReadRect.Left = CON_LEFT;
+    srctReadRect.Bottom = CON_BOTTOM; /* bot. right: row 1, col 79 */
+    srctReadRect.Right = CON_RIGHT;
+       
+    coordBufSize.Y = CON_BOTTOM-CON_TOP+1;
+    coordBufSize.X = CON_RIGHT-CON_LEFT+1;
+       
+    coordBufCoord.X = CON_TOP;
+    coordBufCoord.Y = CON_LEFT;
+    WriteConsoleOutput(
+        hStdout, /* screen buffer to write to    */
+        chiBuffer,        /* buffer to copy from          */
+        coordBufSize,     /* col-row size of chiBuffer    */
+        coordBufCoord, /* top left src cell in chiBuffer  */
+        &srctReadRect); /* dest. screen buffer rectangle */
+       // end restore screen
+    
+}
+
+CHAR_INFO* newBuffer() {
+    CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo;
+    HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
+    GetConsoleScreenBufferInfo(hStdout, &ConsoleInfo);
+    CHAR_INFO * chiBuffer;
+    chiBuffer = new CHAR_INFO[(CON_BOTTOM-CON_TOP+1)*(CON_RIGHT-CON_LEFT+1)];
+       return chiBuffer;
+}
+
+void deleteBuffer(CHAR_INFO* chiBuffer) {
+       delete[] chiBuffer;
+}
+
diff --git a/rosapps/net/telnet/src/tconsole.h b/rosapps/net/telnet/src/tconsole.h
new file mode 100644 (file)
index 0000000..599fd2b
--- /dev/null
@@ -0,0 +1,172 @@
+#ifndef __TNPARSER_H
+#define __TNPARSER_H
+
+#include "tnconfig.h"
+
+/* A diagram of the following values:
+ *
+ *           (0,0)
+ *              +----------------------------------------+
+ *              |                                        |
+ *              |                                        |
+ *              |                                        |
+ *              |                                        |
+ *              |                                        |
+ *              |                                        |
+ *              |                                        |
+ *              |                                        |
+ *              |                                        |
+ *              |                                        |
+ *              |                                        |
+ *              |                                        |
+ *              |                                        |
+ *              |          CON_TOP                       |
+ *              +---------------------------+.....?......|     ---
+ *              |              .            |            |      |
+ *              |              .            | <-- OR --> |      |
+ *              |              .            |            |      |
+ *  CON_LEFT    |              .            | CON_RIGHT  |      
+ *    (=0)      |              .            | (=CON_     |  CON_LINES
+ *              |..............*            |   WIDTH)   |      
+ *              |            (CON_CUR_X,    |            |      |
+ *              |             CON_CUR_Y)    |            |      |
+ *              |                           |            |      |
+ *              |                           |            |      |
+ *              |                           |            |      |
+ *              +---------------------------+------------+     ---
+ *                   CON_BOTTOM (=CON_TOP + CON_HEIGHT)
+ *
+ *              |--------- CON_COLS --------|
+ *
+ * Keep in mind that CON_TOP, CON_BOTTOM, CON_LEFT, and CON_RIGHT are relative
+ * to zero, but CON_CUR_X, CON_CUR_Y, CON_WIDTH, and CON_HEIGHT are relative to
+ * CON_TOP and CON_LEFT
+ */
+
+#define CON_TOP                ConsoleInfo.srWindow.Top
+#define CON_BOTTOM     ConsoleInfo.srWindow.Bottom
+
+#define CON_LEFT       0
+#define CON_RIGHT      (ConsoleInfo.dwSize.X - 1)
+
+#define CON_HEIGHT     (CON_BOTTOM - CON_TOP)
+#define CON_WIDTH      (CON_RIGHT - CON_LEFT)
+#define CON_LINES      (CON_HEIGHT + 1)
+#define CON_COLS       (CON_WIDTH + 1)
+
+#define CON_CUR_X      (ConsoleInfo.dwCursorPosition.X - CON_LEFT)
+#define CON_CUR_Y      (ConsoleInfo.dwCursorPosition.Y - CON_TOP)
+
+
+class TConsole {
+public:
+       TConsole(HANDLE hConsole);
+       ~TConsole();
+       void sync();
+
+       // Cursor movement routines
+    int GetRawCursorX() {return CON_CUR_X;}
+    int GetRawCursorY() {return CON_CUR_Y;}
+    int GetCursorX() {return CON_CUR_X;}
+    int GetCursorY() {
+               if(iScrollStart != -1)
+                       return CON_CUR_Y - iScrollStart;
+               return GetRawCursorY();
+       }
+       void SetRawCursorPosition(int x, int y);
+       void SetCursorPosition(int x, int y);
+       void SetCursorSize(int pct);
+       void MoveCursorPosition(int x, int y);
+       
+       // Screen mode/size routines
+    int GetWidth() {return CON_COLS;}
+    int GetHeight() {return CON_LINES;}
+       void SetExtendedMode(int iFunction, BOOL bEnable);
+       void SetWindowSize(int width, int height);      // Set the size of the window,
+                                                                                               // but not the buffer
+   
+       // Color/attribute routines     
+       void SetAttrib(unsigned char wAttr) {wAttributes = wAttr;}
+    unsigned char GetAttrib() {return wAttributes;}
+    void Normal();                                                             // Reset all attributes
+    void HighVideo();                                                  // Aka "bold"
+    void LowVideo();
+    void SetForeground(unsigned char wAttrib); // Set the foreground directly
+    void SetBackground(unsigned char wAttrib);
+    void BlinkOn();                                                            // Blink on/off
+    void BlinkOff();
+       void UnderlineOn();                                                     // Underline on/off
+       void UnderlineOff();
+       void UlBlinkOn();                                                       // Blink+Underline on/off
+       void UlBlinkOff();
+    void ReverseOn();                                                  // Reverse on/off
+    void ReverseOff();
+       void Lightbg();                                                         // High-intensity background
+       void Darkbg();                                                          // Low-intensity background
+       void setDefaultFg(unsigned char u) {defaultfg = u;}
+       void setDefaultBg(unsigned char u) {defaultbg = u;}
+
+       // Text output routines
+       unsigned long WriteText(const char *pszString, unsigned long cbString);
+       unsigned long WriteString(const char* pszString, unsigned long cbString);
+       unsigned long WriteStringFast(const char *pszString, unsigned long cbString);
+       unsigned long WriteCtrlString(const char* pszString, unsigned long cbString);
+       unsigned long WriteCtrlChar(char c);
+       unsigned long NetWriteString(const char* pszString, unsigned long cbString);
+
+       // Clear screen/screen area functions
+       void ClearScreen(char c = ' ');
+       void ClearWindow(int start, int end, char c = ' ');
+       void ClearEOScreen(char c = ' ');
+       void ClearBOScreen(char c = ' ');
+       void ClearLine(char c = ' ');
+       void ClearEOLine(char c = ' ');
+       void ClearBOLine(char c = ' ');
+
+       // Scrolling and text output control functions
+       void SetScroll(int start, int end);
+    void ScrollDown(int iStartRow , int iEndRow, int bUp);
+       void ScrollAll(int bUp) {ScrollDown(iScrollStart, iScrollEnd, bUp);}
+       void index();
+       void reverse_index();
+       void setLineWrap(bool bEnabled){
+               if(!ini.get_lock_linewrap()) 
+                       ini.set_value("Wrap_Line", bEnabled ? "true" : "false");
+       }
+       bool getLineWrap() {return ini.get_wrapline();}
+
+    // Insert/delete characters/lines
+       void InsertLine(int numlines);                  // Added by Titus von Boxberg 30/3/97           
+    void InsertCharacter(int numchar);         // "
+    void DeleteCharacter(int numchar);         // "
+       void InsertMode(int i) {insert_mode = i;}
+
+       // Miscellaneous functions
+       void Beep();
+
+protected:
+       HANDLE hConsole;
+
+       CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo;
+       
+       unsigned char wAttributes;
+       unsigned char fg, bg;
+       unsigned char defaultfg, defaultbg;
+       unsigned char origfg, origbg;
+
+       bool blink;
+       bool underline;
+       bool reverse;
+       
+       int iScrollStart;
+       int iScrollEnd;
+       int insert_mode;
+};
+
+// Non-member functions for saving state -- used by the scrollback buffer viewer
+void saveScreen(CHAR_INFO* chiBuffer);
+void restoreScreen(CHAR_INFO* chiBuffer);
+CHAR_INFO* newBuffer();
+void deleteBuffer(CHAR_INFO* chiBuffer);
+
+#endif
diff --git a/rosapps/net/telnet/src/telnet.h b/rosapps/net/telnet/src/telnet.h
new file mode 100644 (file)
index 0000000..dbb2cde
--- /dev/null
@@ -0,0 +1,305 @@
+#ifndef ___TELNET_H
+#define ___TELNET_H
+
+/*
+* Copyright (c) 1983 Regents of the University of California.
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms are permitted provided
+* that: (1) source distributions retain this entire copyright notice and
+* comment, and (2) distributions including binaries display the following
+* acknowledgement:  ``This product includes software developed by the
+* University of California, Berkeley and its contributors'' in the
+* documentation or other materials provided with the distribution and in
+* all advertising materials mentioning features or use of this software.
+* 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+*
+*      @(#)telnet.h    5.12 (Berkeley) 3/5/91
+*/
+
+// This file modified 5/15/98 by Paul Brannan.
+// Added (unsigned char) to the #defines.
+// Formatted for readability.
+
+/*
+* Definitions for the TELNET protocol.
+*/
+#define        IAC             (unsigned char)255              /* interpret as command: */
+#define        DONT    (unsigned char)254              /* you are not to use option */
+#define        DO              (unsigned char)253              /* please, you use option */
+#define        WONT    (unsigned char)252              /* I won't use option */
+#define        WILL    (unsigned char)251              /* I will use option */
+#define        SB              (unsigned char)250              /* interpret as subnegotiation */
+#define        GA              (unsigned char)249              /* you may reverse the line */
+#define        EL              (unsigned char)248              /* erase the current line */
+#define        EC              (unsigned char)247              /* erase the current character */
+#define        AYT             (unsigned char)246              /* are you there */
+#define        AO              (unsigned char)245              /* abort output--but let prog finish */
+#define        IP              (unsigned char)244              /* interrupt process--permanently */
+#define        BREAK   (unsigned char)243              /* break */
+#define        DM              (unsigned char)242              /* data mark--for connect. cleaning */
+#define        NOP             (unsigned char)241              /* nop */
+#define        SE              (unsigned char)240              /* end sub negotiation */
+#define EOR     (unsigned char)239             /* end of record (transparent mode) */
+#define        ABORT   (unsigned char)238              /* Abort process */
+#define        SUSP    (unsigned char)237              /* Suspend process */
+#define        xEOF    (unsigned char)236              /* End of file: EOF is already used... */
+
+#define SYNCH  (unsigned char)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", 0,
+};
+#else
+extern char *telcmds[];
+#endif
+
+#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]
+
+/* telnet options */
+#define TELOPT_BINARY                  (unsigned char)0        /* 8-bit data path */
+#define TELOPT_ECHO                            (unsigned char)1        /* echo */
+#define        TELOPT_RCP                              (unsigned char)2        /* prepare to reconnect */
+#define        TELOPT_SGA                              (unsigned char)3        /* suppress go ahead */
+#define        TELOPT_NAMS                             (unsigned char)4        /* approximate message size */
+#define        TELOPT_STATUS                   (unsigned char)5        /* give status */
+#define        TELOPT_TM                               (unsigned char)6        /* timing mark */
+#define        TELOPT_RCTE                             (unsigned char)7        /* remote controlled transmission and echo */
+#define TELOPT_NAOL                            (unsigned char)8        /* negotiate about output line width */
+#define TELOPT_NAOP                            (unsigned char)9        /* negotiate about output page size */
+#define TELOPT_NAOCRD                  (unsigned char)10       /* negotiate about CR disposition */
+#define TELOPT_NAOHTS                  (unsigned char)11       /* negotiate about horizontal tabstops */
+#define TELOPT_NAOHTD                  (unsigned char)12       /* negotiate about horizontal tab disposition */
+#define TELOPT_NAOFFD                  (unsigned char)13       /* negotiate about formfeed disposition */
+#define TELOPT_NAOVTS                  (unsigned char)14       /* negotiate about vertical tab stops */
+#define TELOPT_NAOVTD                  (unsigned char)15       /* negotiate about vertical tab disposition */
+#define TELOPT_NAOLFD                  (unsigned char)16       /* negotiate about output LF disposition */
+#define TELOPT_XASCII                  (unsigned char)17       /* extended ascic character set */
+#define        TELOPT_LOGOUT                   (unsigned char)18       /* force logout */
+#define        TELOPT_BM                               (unsigned char)19       /* byte macro */
+#define        TELOPT_DET                              (unsigned char)20       /* data entry terminal */
+#define        TELOPT_SUPDUP                   (unsigned char)21       /* supdup protocol */
+#define        TELOPT_SUPDUPOUTPUT             (unsigned char)22       /* supdup output */
+#define        TELOPT_SNDLOC                   (unsigned char)23       /* send location */
+#define        TELOPT_TTYPE                    (unsigned char)24       /* terminal type */
+#define        TELOPT_EOR                              (unsigned char)25       /* end or record */
+#define        TELOPT_TUID                             (unsigned char)26       /* TACACS user identification */
+#define        TELOPT_OUTMRK                   (unsigned char)27       /* output marking */
+#define        TELOPT_TTYLOC                   (unsigned char)28       /* terminal location number */
+#define        TELOPT_3270REGIME               (unsigned char)29       /* 3270 regime */
+#define        TELOPT_X3PAD                    (unsigned char)30       /* X.3 PAD */
+#define        TELOPT_NAWS                             (unsigned char)31       /* window size */
+#define        TELOPT_TSPEED                   (unsigned char)32       /* terminal speed */
+#define        TELOPT_LFLOW                    (unsigned char)33       /* remote flow control */
+#define TELOPT_LINEMODE                        (unsigned char)34       /* Linemode option */
+#define TELOPT_XDISPLOC                        (unsigned char)35       /* X Display Location */
+#define TELOPT_ENVIRON                 (unsigned char)36       /* Environment variables */
+#define        TELOPT_AUTHENTICATION   (unsigned char)37       /* Authenticate */
+#define        TELOPT_ENCRYPT                  (unsigned char)38       /* Encryption option */
+#define        TELOPT_EXOPL                    (unsigned char)255      /* extended-options-list */
+
+
+#define        NTELOPTS        (1+TELOPT_ENCRYPT)
+#ifdef TELOPTS
+char *telopts[NTELOPTS+1] = {
+       "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", "XDISPLOC", "ENVIRON", "AUTHENTICATION",
+               "ENCRYPT",
+               0,
+};
+#define        TELOPT_FIRST    TELOPT_BINARY
+#define        TELOPT_LAST     TELOPT_ENCRYPT
+#define        TELOPT_OK(x)    ((x) <= TELOPT_LAST && (x) >= TELOPT_FIRST)
+#define        TELOPT(x)       telopts[(x)-TELOPT_FIRST]
+#endif
+
+/* sub-option qualifiers */
+#define        TELQUAL_IS              (unsigned char)0        /* option is... */
+#define        TELQUAL_SEND    (unsigned char)1        /* send option */
+#define        TELQUAL_INFO    (unsigned char)2        /* ENVIRON: informational version of IS */
+#define        TELQUAL_REPLY   (unsigned char)2        /* AUTHENTICATION: client version of IS */
+#define        TELQUAL_NAME    (unsigned char)3        /* AUTHENTICATION: client version of IS */
+
+/*
+* 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_SOFT_TAB  0x08
+#define MODE_LIT_ECHO  0x10
+
+#define        MODE_MASK       0x1f
+
+/* Not part of protocol, but needed to simplify things... */
+#define MODE_FLOW              0x0100
+#define MODE_ECHO              0x0200
+#define MODE_INBIN             0x0400
+#define MODE_OUTBIN            0x0800
+#define MODE_FORCE             0x1000
+
+#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
+
+/*
+* For backwards compatability, we define SLC_NAMES to be the
+* list of names if SLC_NAMES is not defined.
+*/
+#define        SLC_NAMELIST    "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \
+       "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \
+"LNEXT", "XON", "XOFF", "FORW1", "FORW2", 0,
+#ifdef SLC_NAMES
+//char *slc_names[] = {
+//     SLC_NAMELIST
+//};
+#else
+extern char *slc_names[];
+#define        SLC_NAMES SLC_NAMELIST
+#endif
+
+#define        SLC_NAME_OK(x)  ((x) >= 0 && (x) < NSLC)
+#define SLC_NAME(x)    slc_names[x]
+
+#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
+
+#define        ENV_VALUE       0
+#define        ENV_VAR         1
+#define        ENV_ESC         2
+
+/*
+* AUTHENTICATION suboptions
+*/
+
+/*
+* Who is authenticating who ...
+*/
+#define        AUTH_WHO_CLIENT         0       /* Client authenticating server */
+#define        AUTH_WHO_SERVER         1       /* Server authenticating client */
+#define        AUTH_WHO_MASK           1
+
+/*
+* amount of authentication done
+*/
+#define        AUTH_HOW_ONE_WAY        0
+#define        AUTH_HOW_MUTUAL         2
+#define        AUTH_HOW_MASK           2
+
+#define        AUTHTYPE_NULL           0
+#define        AUTHTYPE_KERBEROS_V4    1
+#define        AUTHTYPE_KERBEROS_V5    2
+#define        AUTHTYPE_SPX            3
+#define        AUTHTYPE_MINK           4
+#define        AUTHTYPE_CNT            5
+
+#define        AUTHTYPE_TEST           99
+
+#ifdef AUTH_NAMES
+char *authtype_names[] = {
+       "NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", 0,
+};
+#else
+extern char *authtype_names[];
+#endif
+
+#define        AUTHTYPE_NAME_OK(x)     ((x) >= 0 && (x) < AUTHTYPE_CNT)
+#define        AUTHTYPE_NAME(x)        authtype_names[x]
+
+/*
+* ENCRYPTion suboptions
+*/
+#define        ENCRYPT_IS              0       /* I pick encryption type ... */
+#define        ENCRYPT_SUPPORT         1       /* I support encryption types ... */
+#define        ENCRYPT_REPLY           2       /* Initial setup response */
+#define        ENCRYPT_START           3       /* Am starting to send encrypted */
+#define        ENCRYPT_END             4       /* Am ending encrypted */
+#define        ENCRYPT_REQSTART        5       /* Request you start encrypting */
+#define        ENCRYPT_REQEND          6       /* Request you send encrypting */
+#define        ENCRYPT_ENC_KEYID       7
+#define        ENCRYPT_DEC_KEYID       8
+#define        ENCRYPT_CNT             9
+
+#define        ENCTYPE_ANY             0
+#define        ENCTYPE_DES_CFB64       1
+#define        ENCTYPE_DES_OFB64       2
+#define        ENCTYPE_CNT             3
+
+#ifdef ENCRYPT_NAMES
+char *encrypt_names[] = {
+       "IS", "SUPPORT", "REPLY", "START", "END",
+               "REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
+               0,
+};
+char *enctype_names[] = {
+       "ANY", "DES_CFB64",  "DES_OFB64",  0,
+};
+#else
+extern char *encrypt_names[];
+extern char *enctype_names[];
+#endif
+
+
+#define        ENCRYPT_NAME_OK(x)      ((x) >= 0 && (x) < ENCRYPT_CNT)
+#define        ENCRYPT_NAME(x)         encrypt_names[x]
+
+#define        ENCTYPE_NAME_OK(x)      ((x) >= 0 && (x) < ENCTYPE_CNT)
+#define        ENCTYPE_NAME(x)         enctype_names[x]
+//////////////////////////////////////////////////////
+//////////////////////////////////////////////////////
+
+
+
+#endif
+
diff --git a/rosapps/net/telnet/src/tkeydef.cpp b/rosapps/net/telnet/src/tkeydef.cpp
new file mode 100644 (file)
index 0000000..c8d058d
--- /dev/null
@@ -0,0 +1,135 @@
+///////////////////////////////////////////////////////////////////////////////
+//Telnet Win32 : an ANSI telnet client.
+//Copyright (C) 1998-2000 Paul Brannan
+//Copyright (C) 1998 I.Ioannou
+//Copyright (C) 1997 Brad Johnson
+//
+//This program is free software; you can redistribute it and/or
+//modify it under the terms of the GNU General Public License
+//as published by the Free Software Foundation; either version 2
+//of the License, or (at your option) any later version.
+//
+//This program is distributed in the hope that it will be useful,
+//but WITHOUT ANY WARRANTY; without even the implied warranty of
+//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//GNU General Public License for more details.
+//
+//You should have received a copy of the GNU General Public License
+//along with this program; if not, write to the Free Software
+//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+//I.Ioannou
+//roryt@hol.gr
+//
+///////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////
+//     Class TkeyDef - Key Definitions                 //
+//                   - kept in an array container      //
+//     originally part of KeyTrans.cpp                 //
+/////////////////////////////////////////////////////////
+
+#include "tkeydef.h"
+
+// This class did not properly release memory before, and a buffer overrun
+// was apparent in operator=(char*).  Fixed.  (Paul Brannan Feb. 4, 1999)
+
+TKeyDef::TKeyDef() {
+       uKeyDef.szKeyDef = 0;
+       vk_code = dwState = 0;
+}
+
+TKeyDef::TKeyDef(char *def, DWORD state, DWORD code) {
+       uKeyDef.szKeyDef = 0;
+       if (def != NULL && *def != 0) {
+               // szKeyDef = (char *) GlobalAlloc(GPTR, strlen(def) +1);
+               uKeyDef.szKeyDef = new char[strlen(def)+1];
+               strcpy(uKeyDef.szKeyDef, def);
+       }
+       dwState = state;
+       vk_code = code;
+}
+
+TKeyDef::TKeyDef(optype op, DWORD state, DWORD code) {
+       uKeyDef.op = new optype;
+       uKeyDef.op->sendstr = 0;
+       uKeyDef.op->the_op = op.the_op;
+       dwState = state;
+       vk_code = code;
+}
+
+TKeyDef::TKeyDef(const TKeyDef &t) {
+       if(t.uKeyDef.szKeyDef == NULL) {
+               uKeyDef.szKeyDef = (char *)NULL;
+       } else if(t.uKeyDef.op->sendstr == 0) {
+               uKeyDef.op = new optype;
+               uKeyDef.op->sendstr = 0;
+               uKeyDef.op->the_op = t.uKeyDef.op->the_op;
+       } else {
+               uKeyDef.szKeyDef = new char[strlen(t.uKeyDef.szKeyDef)+1];
+               strcpy(uKeyDef.szKeyDef, t.uKeyDef.szKeyDef);
+       }
+       dwState = t.dwState;
+       vk_code = t.vk_code;
+}
+
+TKeyDef::~TKeyDef() {
+       if(uKeyDef.szKeyDef) delete[] uKeyDef.szKeyDef;
+}
+
+char * TKeyDef::operator=(char *def) {
+       if(def != NULL && *def != 0) {
+               if(uKeyDef.szKeyDef) delete[] uKeyDef.szKeyDef;
+               uKeyDef.szKeyDef = new char[strlen(def)+1];
+               strcpy(uKeyDef.szKeyDef, def);
+       }
+       return uKeyDef.szKeyDef;
+}
+
+DWORD TKeyDef::operator=(DWORD code) {
+       return vk_code = code;
+}
+
+TKeyDef& TKeyDef::operator=(const TKeyDef &t) {
+       if(t.uKeyDef.szKeyDef) {
+               if(uKeyDef.szKeyDef) delete[] uKeyDef.szKeyDef;
+               if(t.uKeyDef.op->sendstr) {
+                       uKeyDef.szKeyDef = new char[strlen(t.uKeyDef.szKeyDef)+1];
+                       strcpy(uKeyDef.szKeyDef, t.uKeyDef.szKeyDef);
+               } else {
+                       uKeyDef.op = new optype;
+                       uKeyDef.op->sendstr = 0;
+                       uKeyDef.op->the_op = t.uKeyDef.op->the_op;
+               }
+       } else {
+               uKeyDef.szKeyDef = (char *)NULL;
+       }
+       dwState = t.dwState;
+       vk_code = t.vk_code;
+       return *this;
+}
+
+const optype& TKeyDef::operator=(optype op) {
+       uKeyDef.op = new optype;
+       uKeyDef.op->sendstr = 0;
+       uKeyDef.op->the_op = op.the_op;
+       return *uKeyDef.op;
+}
+
+// STL requires that operators be friends rather than member functions
+// (Paul Brannan 5/25/98)
+#ifndef __BORLANDC__
+bool operator==(const TKeyDef & t1, const TKeyDef & t2) {
+       return ((t1.vk_code == t2.vk_code) && (t1.dwState == t2.dwState));
+}
+// We need this function for compatibility with STL (Paul Brannan 5/25/98)
+bool operator< (const TKeyDef& t1, const TKeyDef& t2) {
+       if (t1.vk_code == t2.vk_code) return t1.dwState < t2.dwState;
+       return t1.vk_code < t2.vk_code;
+}
+#else
+int   TKeyDef::operator==(TKeyDef & t) {
+       return ((vk_code == t.vk_code) && (dwState == t.dwState));
+}
+#endif
+
diff --git a/rosapps/net/telnet/src/tkeydef.h b/rosapps/net/telnet/src/tkeydef.h
new file mode 100644 (file)
index 0000000..69bc92a
--- /dev/null
@@ -0,0 +1,71 @@
+/////////////////////////////////////////////////////////
+//                      TkeyDef - Key Definitions class           //
+//                   - keeped in an array container    //
+/////////////////////////////////////////////////////////
+
+#ifndef __TKEYDEF_H
+#define __TKEYDEF_H
+
+#include <windows.h>
+
+#ifndef __BORLANDC__ // Ioannou Dec. 8, 1998
+// We need these for MSVC6 (Sam Robertson Oct. 8, 1998)
+class TKeyDef;
+bool operator==(const TKeyDef &t1, const TKeyDef &t2);
+bool operator<(const TKeyDef &t1, const TKeyDef &t2);
+////
+#endif
+
+// Paul Brannan Feb. 5, 1999
+enum tn_ops {TN_ESCAPE, TN_SCROLLBACK, TN_DIAL, TN_PASTE, TN_NULL, TN_CR, TN_CRLF};
+
+typedef struct {
+       char sendstr;
+       tn_ops the_op;
+} optype;
+
+union KeyDefType {
+       char *szKeyDef;
+       optype *op;
+};
+
+union KeyDefType_const {
+       const char *szKeyDef;
+       const optype *op;
+};
+
+class TKeyDef {
+private:
+       KeyDefType      uKeyDef;
+       DWORD           vk_code;
+       DWORD           dwState;
+       
+public:
+       TKeyDef();
+       TKeyDef(char *def, DWORD state, DWORD code);
+       TKeyDef(optype op, DWORD state, DWORD code);
+       TKeyDef(const TKeyDef &t);
+       
+       char *operator=(char *def);
+       DWORD  operator=(DWORD code);
+       TKeyDef& operator=(const TKeyDef &t);
+       const optype& operator=(optype op);
+               
+       ~TKeyDef();
+       
+#ifdef __BORLANDC__
+       int operator==(TKeyDef &t);
+#else
+       // made these into friends for compatibility with stl
+       // (Paul Brannan 5/7/98)
+       friend bool operator==(const TKeyDef &t1, const TKeyDef &t2);
+       friend bool operator<(const TKeyDef &t1, const TKeyDef &t2);
+#endif
+       
+       const char *GetszKey() { return uKeyDef.szKeyDef; }
+       const KeyDefType GetKeyDef() { return uKeyDef; }
+       DWORD GetCodeKey() { return vk_code; }
+
+};
+
+#endif
\ No newline at end of file
diff --git a/rosapps/net/telnet/src/tkeymap.cpp b/rosapps/net/telnet/src/tkeymap.cpp
new file mode 100644 (file)
index 0000000..e1730f5
--- /dev/null
@@ -0,0 +1,62 @@
+///////////////////////////////////////////////////////////////////////////////
+//Telnet Win32 : an ANSI telnet client.
+//Copyright (C) 1998-2000 Paul Brannan
+//Copyright (C) 1998 I.Ioannou
+//Copyright (C) 1997 Brad Johnson
+//
+//This program is free software; you can redistribute it and/or
+//modify it under the terms of the GNU General Public License
+//as published by the Free Software Foundation; either version 2
+//of the License, or (at your option) any later version.
+//
+//This program is distributed in the hope that it will be useful,
+//but WITHOUT ANY WARRANTY; without even the implied warranty of
+//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//GNU General Public License for more details.
+//
+//You should have received a copy of the GNU General Public License
+//along with this program; if not, write to the Free Software
+//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+//I.Ioannou
+//roryt@hol.gr
+//
+///////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////
+//     Class TkeyMap - Key Mappings                    //
+//                   - kept in an array container      //
+//     originally part of KeyTrans.cpp                 //
+/////////////////////////////////////////////////////////
+
+#include "tkeymap.h"
+
+KeyMap::KeyMap(DWORD state, DWORD code): map(0,0,sizeof(TKeyDef)),
+                                         key(NULL,state,code) {};
+
+KeyMap::KeyMap(TKeyDef&tk):map(0,0,sizeof(TKeyDef)){
+  key = tk;
+};
+KeyMap::KeyMap(TKeyDef&tk, string& t):map(0,0,sizeof(TKeyDef)), orig(t){
+  key = tk;
+};
+
+int KeyMap::operator==(const KeyMap & t) const{
+    return key == t.key;
+};
+
+KeyMap& KeyMap::operator = (const KeyMap& t){
+     key = t.key;
+     map = t.map;
+     orig = t.orig;
+     return (*this);
+};
+
+#ifndef __BORLANDC__
+bool operator<(const KeyMap &t1, const KeyMap &t2) {
+       return t1.key < t2.key;
+}
+#endif
+
+KeyMap::~KeyMap() {
+};
diff --git a/rosapps/net/telnet/src/tkeymap.h b/rosapps/net/telnet/src/tkeymap.h
new file mode 100644 (file)
index 0000000..965e21d
--- /dev/null
@@ -0,0 +1,39 @@
+#ifndef __TKEYMAP_H
+#define __TKEYMAP_H
+
+#ifdef __BORLANDC__
+#include <classlib\arrays.h>
+#else
+#include <string>
+#include "stl_bids.h"
+#endif
+
+#include "tkeydef.h"
+
+//AVS
+typedef TArrayAsVector<TKeyDef> keyArray;
+
+//AVS
+// representation of keymap
+struct KeyMap {
+       keyArray  map;                                          // keymap
+       string    orig;                                         // original string from .cfg file
+       TKeyDef   key;                                          // 'switch to' key
+
+       KeyMap(DWORD state, DWORD code);
+       KeyMap(): map(0,0,sizeof(TKeyDef)){};
+       KeyMap(TKeyDef&tk);
+       KeyMap(TKeyDef&tk, string&);
+       KeyMap(const string&t): map(0,0,sizeof(TKeyDef)), orig(t) {};
+       int   operator==(const KeyMap & t) const;
+          KeyMap& operator = (const KeyMap& t);
+
+#ifndef __BORLANDC__
+          // The STL needs this (Paul Brannan 5/25/98)
+          friend bool operator<(const KeyMap &t1, const KeyMap &t2);
+#endif
+
+       ~KeyMap();
+};
+
+#endif
\ No newline at end of file
diff --git a/rosapps/net/telnet/src/tmapldr.cpp b/rosapps/net/telnet/src/tmapldr.cpp
new file mode 100644 (file)
index 0000000..de41cbb
--- /dev/null
@@ -0,0 +1,773 @@
+///////////////////////////////////////////////////////////////////////////////
+//Telnet Win32 : an ANSI telnet client.
+//Copyright (C) 1998-2000 Paul Brannan
+//Copyright (C) 1998 I.Ioannou
+//Copyright (C) 1997 Brad Johnson
+//
+//This program is free software; you can redistribute it and/or
+//modify it under the terms of the GNU General Public License
+//as published by the Free Software Foundation; either version 2
+//of the License, or (at your option) any later version.
+//
+//This program is distributed in the hope that it will be useful,
+//but WITHOUT ANY WARRANTY; without even the implied warranty of
+//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//GNU General Public License for more details.
+//
+//You should have received a copy of the GNU General Public License
+//along with this program; if not, write to the Free Software
+//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+//I.Ioannou
+//roryt@hol.gr
+//
+///////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////
+//     Class TMapLoader - Key/Character Mappings       //
+//                      - Loads from telnet.cfg        //
+//     originally part of KeyTrans.cpp                 //
+/////////////////////////////////////////////////////////
+
+#ifdef __BORLANDC__
+#include <fstream.h>
+#else
+#include <string>
+#include <fstream>
+#endif
+
+#include "tmapldr.h"
+#include "tnerror.h"
+#include "tnconfig.h"
+
+// It's probably a good idea to turn off the "identifier was truncated" warning
+// in MSVC (Paul Brannan 5/25/98)
+#ifdef _MSC_VER
+#pragma warning(disable: 4786)
+#endif
+
+// AVS
+// skip inline comments, empty lines
+static char * getline(istream& i, char* buf, int size){
+       
+       int len = 0;
+       
+       while (1) {
+               memset(buf,0,size);
+               if (i.eof()) break;
+               i.getline(buf,size,'\n');
+               
+               while (buf[len]) {
+                       if ( /*(buf[len]>=0) &&*/ buf[len]< ' ' ) buf[len] = ' ';
+                       len++;
+               };
+               len = 0;
+               
+               // not so fast, but work ;)
+               while ( buf[len] ) {
+            if ( (buf[len] == ' ') && (buf[len+1] == ' ')) {
+                               memmove(buf+len, buf+len+1, strlen(buf+len));
+            } else len++;
+               };
+               
+               if (buf[0] == ' ') memmove(buf, buf+1, size-1);
+               
+               // empty or comment
+               if ((buf[0]==0)||(buf[0]==';')) continue;
+               
+               len = 0; // look for comment like this one
+               while (buf[len])
+                       if ((buf[len] == '/') && (buf[len+1] == '/')) buf[len] = 0;
+                       else len++;
+                       
+                       if (len && (buf[len-1] == ' ')) {
+                len--;
+                buf[len]=0;
+                       };
+                       // in case for comment like this one (in line just a comment)
+                       if (buf[0]==0) continue;
+                       
+                       break;
+       };
+       return (buf);
+};
+
+//AVS
+// use string as FIFO queue for lines
+static int getline(string&str, char* buf, size_t sz) {
+       
+       if ( !str.length() ) return 0;
+       const char * p = strchr(str.c_str(),'\n');
+       unsigned int len; // Changed to unsigned (Paul Brannan 6/23/98)
+       if ( p==NULL )
+               len = str.length();
+       else
+               len = p - str.c_str();
+       
+       len = len<sz?len:sz-1;
+       
+       strncpy(buf,str.c_str(), len);
+       buf[len]=0;
+       // DJGPP also uses erase rather than remove (Paul Brannan 6/23/98)
+#ifndef __BORLANDC__
+       str.erase(0, len + 1);
+#else
+       str.remove(0,len+1);
+#endif
+       return 1;
+};
+
+//AVS
+// parse \nnn and \Xhh
+static int getbyte(const char*str) {
+       unsigned char retval = 0;
+       int base = 10;
+       int readed = 0;
+       
+       if ( (*str == 'x') || (*str == 'X') ) {
+               base = 16;
+               readed++;
+       };
+       
+       while (readed != 3 && str[readed]) {
+               unsigned char ch = toupper(str[readed]);
+               if ( isdigit(ch) ) {
+                       retval = retval*base + (ch -'0');
+               } else if (base == 16 && ch >= 'A' && ch <= 'F') {
+                       retval = retval*base + (ch-'A'+10);
+               } else {
+                       return -1;
+               };
+               readed++;
+       };
+       // Ioannou: If we discard the 0x00 we can't undefine a key !!!
+       //  if ( retval == 0 ) {
+       //     return -1;
+       //  };
+       return retval;
+};
+
+//AVS
+// a little optimization
+DWORD Fix_ControlKeyState(char * Next_Token) {
+       if (stricmp(Next_Token, "RIGHT_ALT" ) == 0) return RIGHT_ALT_PRESSED;
+       if (stricmp(Next_Token, "LEFT_ALT"  ) == 0) return LEFT_ALT_PRESSED;
+       if (stricmp(Next_Token, "RIGHT_CTRL") == 0) return RIGHT_CTRL_PRESSED;
+       if (stricmp(Next_Token, "LEFT_CTRL" ) == 0) return LEFT_CTRL_PRESSED;
+       if (stricmp(Next_Token, "SHIFT"     ) == 0) return SHIFT_PRESSED;
+       if (stricmp(Next_Token, "NUMLOCK"   ) == 0) return NUMLOCK_ON;
+       if (stricmp(Next_Token, "SCROLLLOCK") == 0) return SCROLLLOCK_ON;
+       if (stricmp(Next_Token, "CAPSLOCK"  ) == 0) return CAPSLOCK_ON;
+       if (stricmp(Next_Token, "ENHANCED"  ) == 0) return ENHANCED_KEY;
+       
+       // Paul Brannan 5/27/98
+       if (stricmp(Next_Token, "APP_KEY"   ) == 0) return APP_KEY;
+       // Paul Brannan 6/28/98
+       if (stricmp(Next_Token, "APP2_KEY"  ) == 0) return APP2_KEY;
+       // Paul Brannan 8/28/98
+       if (stricmp(Next_Token, "APP3_KEY"  ) == 0) return APP3_KEY;
+       // Paul Brannan 12/9/98
+       if (stricmp(Next_Token, "APP4_KEY"  ) == 0) return APP4_KEY;
+       
+       return 0;
+}
+
+
+// AVS
+// rewrited to suppert \xhh notation, a little optimized
+char* Fix_Tok(char * tok) {
+       static char s[256];
+       int i,j,n;
+       
+       // setmem is nonstandard; memset is standard (Paul Brannan 5/25/98)
+       memset(s, 0, 256);
+       //  setmem(s, 256, 0);
+       i = j = n = 0;
+       if ( tok != NULL ) {
+               for ( ; tok[i] != 0; ) {
+                       switch ( tok[i] ) {
+                       case '\\' :
+                               switch ( tok[i+1] ) {
+                               case '\\':
+                                       s[j++] = '\\';
+                                       i += 2;
+                                       break;
+                               default:
+                                       n = getbyte(tok+i+1);
+                                       if ( n < 0 )
+                                               s[j++] = tok[i++];
+                                       else {
+                                               s[j++]=n;
+                                               i += 4;
+                                       } ;
+                                       break;
+                               };
+                               break;
+                               case '^' :
+                    if ( tok[i+1] >= '@' ) {
+                                               s[j++] = tok[i+1] - '@';
+                                               i += 2;
+                                               break;
+                    }
+                               default  :
+                    s[j++] = tok[i++];
+                       }
+               }
+       }
+       return s;
+};
+
+// AVS
+// perform 'normalization' for lines like [some text], and some checks
+// maybe it will be done faster - but no time for it
+int normalizeSplitter(string& buf) {
+    if ( buf.length() <= 2 ) return 0;
+    if ( buf[0] == '[' && buf[buf.length()-1] == ']' ) {
+               while ( buf[1] == ' ' )
+                       // DJGPP also uses erase rather than remove (Paul Brannan 6/23/98)
+#ifndef __BORLANDC__
+                       buf.erase(1, 1);
+#else
+                       buf.remove(1,1);
+#endif
+               while ( buf[buf.length()-2] == ' ' )
+                       // Paul Brannan 6/23/98
+#ifndef __BORLANDC__
+                       buf.erase(buf.length()-2,1);
+#else
+                       buf.remove(buf.length()-2,1);
+#endif
+               return 1;
+    }
+    return 0;
+};
+
+// AVS
+// looking for part in string array, see Load(..) for more info
+int TMapLoader::LookForPart(stringArray& sa, const char* partType, const char* partName) {
+    if ( !sa.IsEmpty() ) {
+               string cmpbuf("[");
+               cmpbuf += partType;
+               cmpbuf += " ";
+               cmpbuf += partName;
+               cmpbuf += "]";
+               normalizeSplitter(cmpbuf); // if no parttype, [global] for example
+               int max = sa.GetItemsInContainer();
+               for ( int i = 0; i<max; i++ )
+                       // I found some strange behavior if strnicmp was used here
+            if (strnicmp(cmpbuf.c_str(),sa[i].c_str(),cmpbuf.length()) == 0)
+                               return i;
+    };
+    return INT_MAX;
+};
+
+// AVS
+// load globals to 'globals'
+// in buf must be a [global] part of input file
+int TMapLoader::LoadGlobal(string& buf) {
+       
+       char wbuf[128];
+       while ( buf.length() ) {
+               wbuf[0]=0;
+               if (!getline(buf,wbuf,sizeof(wbuf))) break;
+               if ( wbuf[0]==0 ) break;
+               char* Name = strtok(wbuf, TOKEN_DELIMITERS);
+               if ( stricmp(Name, "[global]")==0 ) continue;
+               
+               char* Value = strtok(NULL, TOKEN_DELIMITERS);
+               if ( Value == NULL ) {
+                       //              cerr << "[global] -> no value for " << Name << endl;
+                       printm(0, FALSE, MSG_KEYNOVAL, Name);
+                       continue;
+               };
+               int val = atoi(Value);
+               if ( val > 0 && val <= 0xff ) {
+                       if ( !KeyTrans.AddGlobalDef(val, Name)) return 0;
+               }
+               else {
+                       //             cerr << "[global] -> bad value for " << Name << endl;
+                       printm(0, FALSE, MSG_KEYBADVAL, Name);
+                       continue;
+               };
+       };
+       return 1;
+};
+
+// AVS
+// perform parsing of strings like 'VK_CODE shifts text'
+// returns text on success
+char* TMapLoader::ParseKeyDef(const char* buf, WORD& vk_code, DWORD& control) {
+       char wbuf[256];
+       strcpy(wbuf,buf);
+       char* ptr = strtok(wbuf, TOKEN_DELIMITERS);
+       if ( ptr == NULL ) return NULL;
+       
+       int i = KeyTrans.LookOnGlobal(ptr);
+       if ( i == INT_MAX ) return NULL;
+       
+       vk_code = KeyTrans.GetGlobalCode(i);
+       
+       control = 0;
+       DWORD st;
+       while (1) {
+               ptr = strtok(NULL, TOKEN_DELIMITERS);
+               if ((ptr == NULL) || ((st = Fix_ControlKeyState(ptr)) == 0)) break;
+               control |= st;
+       };
+       
+       if ( ptr == NULL ) return NULL;
+       
+       return Fix_Tok(ptr);
+};
+
+// AVS
+// load keymap to current map
+// be aware - buf must passed by value, its destroyed
+int TMapLoader::LoadKeyMap(string buf) {
+       
+       char wbuf[128];
+       WORD vk_code;
+       DWORD control;
+       int i;
+
+       // Paul Brannan Feb. 22, 1999
+       strcpy(wbuf, "VK_");
+       wbuf[4] = 0;
+       wbuf[3] = ini.get_escape_key();
+       i = KeyTrans.LookOnGlobal(wbuf);
+       if (i != INT_MAX) {
+               KeyTrans.AddKeyDef(KeyTrans.GetGlobalCode(i), RIGHT_ALT_PRESSED, TN_ESCAPE);
+               KeyTrans.AddKeyDef(KeyTrans.GetGlobalCode(i), LEFT_ALT_PRESSED, TN_ESCAPE);
+       }
+       wbuf[3] = ini.get_scrollback_key();
+       i = KeyTrans.LookOnGlobal(wbuf);
+       if (i != INT_MAX) {
+               KeyTrans.AddKeyDef(KeyTrans.GetGlobalCode(i), RIGHT_ALT_PRESSED, TN_SCROLLBACK);
+               KeyTrans.AddKeyDef(KeyTrans.GetGlobalCode(i), LEFT_ALT_PRESSED, TN_SCROLLBACK);
+       }
+       wbuf[3] = ini.get_dial_key();
+       i = KeyTrans.LookOnGlobal(wbuf);
+       if (i != INT_MAX) {
+               KeyTrans.AddKeyDef(KeyTrans.GetGlobalCode(i), RIGHT_ALT_PRESSED, TN_DIAL);
+               KeyTrans.AddKeyDef(KeyTrans.GetGlobalCode(i), LEFT_ALT_PRESSED, TN_DIAL);
+       }
+       KeyTrans.AddKeyDef(VK_INSERT, SHIFT_PRESSED, TN_PASTE);
+
+       while ( buf.length() ) {
+               wbuf[0] = 0;
+               if (!getline(buf,wbuf,sizeof(wbuf))) break;
+               if ( wbuf[0]==0 ) break;
+               if ( strnicmp(wbuf,"[keymap",7)==0 ) continue;
+               
+               char * keydef = ParseKeyDef(wbuf,vk_code,control);
+
+               if ( keydef != NULL ) {
+
+                       // Check to see if keydef is a "special" code (Paul Brannan 3/29/00)
+                       if(!strnicmp(keydef, "\\tn_escape", strlen("\\tn_escape"))) {
+                               if(!KeyTrans.AddKeyDef(vk_code, control, TN_ESCAPE)) return 0;
+                       } else if(!strnicmp(keydef, "\\tn_scrollback", strlen("\\tn_scrollback"))) {
+                               if(!KeyTrans.AddKeyDef(vk_code, control, TN_SCROLLBACK)) return 0;
+                       } else if(!strnicmp(keydef, "\\tn_dial", strlen("\\tn_dial"))) {
+                               if(!KeyTrans.AddKeyDef(vk_code, control, TN_DIAL)) return 0;
+                       } else if(!strnicmp(keydef, "\\tn_paste", strlen("\\tn_paste"))) {
+                               if(!KeyTrans.AddKeyDef(vk_code, control, TN_PASTE)) return 0;
+                       } else if(!strnicmp(keydef, "\\tn_null", strlen("\\tn_null"))) {
+                               if(!KeyTrans.AddKeyDef(vk_code, control, TN_NULL)) return 0;
+                       } else if(!strnicmp(keydef, "\\tn_cr", strlen("\\tn_cr"))) {
+                               if(!KeyTrans.AddKeyDef(vk_code, control, TN_CR)) return 0;
+                       } else if(!strnicmp(keydef, "\\tn_crlf", strlen("\\tn_crlf"))) {
+                               if(!KeyTrans.AddKeyDef(vk_code, control, TN_CRLF)) return 0;
+                       } else 
+                               if(!KeyTrans.AddKeyDef(vk_code,control,keydef)) return 0;
+                               // else DeleteKeyDef() ???? - I'm not sure...
+               }
+       };
+
+       return 1;
+};
+
+// AVS
+// load [charmap ...] part to xlat
+int TMapLoader::LoadCharMap(string buf) {
+       char wbuf[128];
+       char charmapname[128];
+       charmapname[0] = 0;
+       
+       //        xlat.init(); now it done by KeyTranslator::Load()
+       
+       while ( buf.length() ) {
+               wbuf[0]=0;
+               if (!getline(buf,wbuf,sizeof(wbuf))) break;
+               if ( wbuf[0]==0 ) break;
+               if ( strnicmp(wbuf,"[charmap",8)==0 ) {
+                       strcpy(charmapname,wbuf);
+                       continue;
+               };
+               char * host = strtok(wbuf, " ");
+               char * console = strtok(NULL, " ");
+               
+               int bHost;
+               int bConsole;
+               
+               if ( host == NULL || console == NULL ) {
+                       //              cerr << charmapname << " -> Bad structure" << endl;
+                       printm(0, FALSE, MSG_KEYBADSTRUCT, charmapname);
+                       return 0;
+               };
+               if ( strlen(host) > 1 && host[0] == '\\' )
+                       bHost = getbyte(host+1);
+               else
+                       bHost = (unsigned char)host[0];
+               
+               if ( strlen(console) > 1 && console[0] == '\\' )
+                       bConsole = getbyte(console+1);
+               else
+                       bConsole = (unsigned char)console[0];
+               
+               if ( bHost <= 0 || bConsole <= 0 ) {
+                       //              cerr << charmapname << " -> Bad chars? "
+                       //                   << host << " -> " << console << endl;
+                       printm(0, FALSE, MSG_KEYBADCHARS, charmapname, host, console);
+                       return 0;
+               };
+               // xlat.table[bHost] = bConsole;
+               Charmap.modmap(bHost, 'B', bConsole);
+       };
+       return (Charmap.enabled = 1);
+       return 1;
+};
+
+// AVS
+// ignore long comment [comment] ... [end comment]
+// recursive!
+int getLongComment(istream& is, char* wbuf, size_t sz) {
+       
+       int bufLen;
+    while ( is ) {
+               wbuf[0] = 0;
+               getline(is, wbuf, sz);
+               if ( wbuf[0]==0 ) return 1;
+               bufLen = strlen(wbuf);
+               if ( wbuf[0] == '[' && wbuf[bufLen-1] == ']' ) {
+                       string temps(wbuf);
+                       
+                       if (!normalizeSplitter(temps)) {
+                               //           cerr << "Unexpected line '" << temps << "'\n";
+                               printm(0, FALSE, MSG_KEYUNEXPLINE, temps.c_str());
+                               return 0;
+                       };
+                       if ( stricmp(temps.c_str(),"[comment]") == 0 ) {
+                               // do recursive call
+                               if ( !getLongComment(is, wbuf, sz) ) return 0;
+                               continue;
+                       };
+                       if ( stricmp(temps.c_str(),"[end comment]") == 0 ) return 1;
+               };
+    };
+       // we get a warning if we don't put a return here (Paul Brannan 5/25/98)
+       return 0;
+};
+
+// AVS
+// completelly rewrited to support new conceptions
+int TMapLoader::Load(const char * filename, const char * szActiveEmul) {
+       char buf[256];
+       int bufLen;
+       
+       ifstream inpfile(filename);
+       KeyTrans.DeleteAllDefs();
+       Charmap.init();
+       
+       // it is an array for store [...] ... [end ...] parts from file
+       stringArray SA(0,0,sizeof(string));
+       int AllOk = 0;
+       
+       while ( inpfile ) {
+               
+               getline(inpfile, buf, 255);
+               bufLen = strlen(buf);
+               if ( !bufLen ) continue;
+               
+               if ( buf[0] == '[' && buf[bufLen-1] == ']' ) {
+                       // is a part splitter [...]
+                       string temps(buf);
+                       
+                       if (!normalizeSplitter(temps)) {
+                               printm(0, FALSE, MSG_KEYUNEXPLINE, temps.c_str());
+                               AllOk = 0;
+                               break;
+                       };
+                       // if a comment
+                       if ( stricmp(temps.c_str(),"[comment]") == 0 ) {
+#ifdef KEYDEBUG
+                               printit(temps.c_str());
+#endif
+                               if ( !getLongComment(inpfile, buf, sizeof(buf)) ) {
+                                       printm(0, FALSE, MSG_KEYUNEXPEOF);
+                                       break;
+                               };
+#ifdef KEYDEBUG
+                               printit("\r          \r");
+#endif
+                               continue;
+                       };
+                       
+                       
+                       string back = temps;
+                       // prepare line for make it as [end ...]
+                       // and check it
+                       if ( strnicmp(back.c_str(), "[global]", 8) == 0 ) {} // do nothing
+                       else if ( strnicmp(back.c_str(), "[keymap", 7) == 0 ) {
+                               // DJGPP also uses erase rather than remove (Paul Brannan 6/23/98)
+#ifndef __BORLANDC__
+                               back.erase(7);
+#else
+                               back.remove(7);
+#endif
+                               back += "]";
+                       }
+                       else if ( strnicmp(back.c_str(), "[charmap", 8) == 0 ) {
+                               // Paul Brannan 6/23/98
+#ifndef __BORLANDC__
+                               back.erase(8);
+#else
+                               back.remove(8);
+#endif
+                               back += "]";
+                       }
+                       else if ( strnicmp(back.c_str(), "[config", 7) == 0 ) {
+                               // Paul Brannan 6/23/98
+#ifndef __BORLANDC__
+                               back.erase(7);
+#else
+                               back.remove(7);
+#endif
+                               back += "]";
+                       }
+                       else {
+                               //        cerr << "Unexpected token " << back << endl;
+                               printm(0, FALSE, MSG_KEYUNEXPTOK, back.c_str());
+                               break;
+                       };
+                       
+                       back.insert(1,"END "); // now it looks like [END ...]
+#ifdef KEYDEBUG
+                       printit(temps.c_str());
+#endif
+                       
+                       int ok = 0;
+                       // fetch it to temps
+                       while ( 1 ) {
+                               getline(inpfile, buf, sizeof(buf));
+                               bufLen = strlen(buf);
+                               if ( !bufLen ) break;
+                               if ( buf[0] == '[' && buf[bufLen-1] == ']' ) {
+                                       string t(buf);
+                                       if ( !normalizeSplitter(t) ) break;
+                                       
+                                       if ( stricmp(t.c_str(),back.c_str()) == 0 ) {
+                                               ok = 1;
+                                               break;
+                                       };
+                                       
+                                       // AVS 31.12.97 fix [comment] block inside another block
+                                       if ( stricmp(t.c_str(),"[comment]") == 0 &&
+                                               getLongComment(inpfile, buf, sizeof(buf)) ) continue;
+                                       
+                                       break;
+                               };
+                               temps += "\n";
+                               temps += buf;
+                       };
+                       if ( !ok ) {
+                               //         cerr << "Unexpected end of file or token" << endl;
+                               printm(0, FALSE, MSG_KEYUNEXP);
+                               AllOk = 0;
+                               break;
+                       };
+#ifdef KEYDEBUG
+                       printit("\r                                                                      \r");
+#endif
+                       AllOk = SA.Add(temps);;
+                       if ( !AllOk ) break;
+               } else {
+                       //       cerr << "Unexpected line '" << buf << "'\n";
+                       printm(0, FALSE, MSG_KEYUNEXPLINE, buf);
+                       AllOk = 0;
+                       break;
+               };
+       };
+       
+       inpfile.close();
+       
+       if ( !AllOk ) return 0;
+       
+       // now all file are in SA, comments are stripped
+       
+       int i = LookForPart(SA, "global", "");
+       if ( i == INT_MAX ) {
+               //     cerr << "No [GLOBAL] definition!" << endl;
+               printm(0, FALSE, MSG_KEYNOGLOBAL);
+               return 0;
+       };
+       if ( !LoadGlobal(SA[i]) ) {
+               return 0;
+       };
+       
+       // look for need configuration
+       i = LookForPart(SA, "config", szActiveEmul);
+       if ( i == INT_MAX ) {
+               //     cerr << "No [CONFIG " << szActiveEmul << "]\n";
+               printm(0, FALSE, MSG_KEYNOCONFIG, szActiveEmul);
+               return 0;
+       };
+       //  cerr << "use configuration: " << szActiveEmul << endl;
+       printm(0, FALSE, MSG_KEYUSECONFIG, szActiveEmul);
+       BOOL hadKeys = FALSE;
+       
+       string config = SA[i];
+       // parse it
+       while ( config.length() ) {
+               buf[0] = 0;
+               getline(config,buf,sizeof(buf));
+               bufLen = strlen(buf);
+               if ( !bufLen || (buf[0] == '[' && buf[bufLen-1] == ']') ) continue;
+               if ( strnicmp(buf,"keymap",6) == 0 ) {
+                       string orig(buf);
+                       printit("\t"); printit(buf); printit("\n");
+                       char * mapdef = strtok(buf,":");
+                       char * switchKey = strtok(NULL,"\n");
+                       
+                       if ( !KeyTrans.mapArray.IsEmpty() && switchKey == NULL ) {
+                               //            cerr << "no switch Key for '" << mapdef
+                               //                 << "'" << endl;
+                               printm(0, FALSE, MSG_KEYNOSWKEY, mapdef);
+                               break;
+                       };
+                       if ( KeyTrans.mapArray.IsEmpty() ) {
+                               if ( switchKey != NULL ) { // create default keymap
+                                       //               cerr << "You cannot define switch key for default keymap -> ignored"
+                                       //                    << endl;
+                                       printm(0, FALSE, MSG_KEYCANNOTDEF);
+                               };
+                               TKeyDef empty;
+                               KeyTrans.mapArray.Add(KeyMap(string(mapdef)));
+                               KeyTrans.switchMap(empty); // set it as current keymap
+                               KeyTrans.mainKeyMap = KeyTrans.currentKeyMap;
+                       }
+                       else {
+                               string keydef(switchKey);
+                               keydef += " !*!*!*"; // just for check
+                               WORD vk_code;
+                               DWORD control;
+                               switchKey = ParseKeyDef(keydef.c_str(),vk_code,control);
+                               if ( switchKey != NULL ) {
+                                       TKeyDef swi(NULL,control,vk_code);
+                                       if ( KeyTrans.switchMap(swi) > 0 ) {
+                                               //                  cerr << "Duplicate switching key\n";
+                                               printm(0, FALSE, MSG_KEYDUPSWKEY);
+                                               break;
+                                       };
+                                       KeyTrans.mapArray.Add(KeyMap(swi, orig));
+                                       KeyTrans.switchMap(swi); // set it as current keymap
+                               }
+                       };
+                       mapdef+=7; // 'keymap '
+                       // now load defined keymaps to current
+                       while ((mapdef != NULL)&&
+                               (mapdef = strtok(mapdef,TOKEN_DELIMITERS)) != NULL ) {
+                               i = LookForPart(SA,"keymap",mapdef);
+                               if ( i == INT_MAX ) {
+                                       //               cerr << "Unknown KEYMAP " << mapdef << endl;
+                                       printm(0, FALSE, MSG_KEYUNKNOWNMAP, mapdef);
+                               } else {
+                                       mapdef = strtok(NULL,"\n"); // strtok is used in LoadKeyMap
+                                       // so - save pointer!
+                                       hadKeys = LoadKeyMap(SA[i]); // load it
+                               };
+                       };
+                       
+               }
+               else if ( strnicmp(buf,"charmap",7) == 0 ) {
+                       printit("\t"); printit(buf); printit("\n");
+                       char * mapdef = buf + 8;// 'charmap '
+                       int SuccesLoaded = 0;
+                       // now load defined charmaps to current
+                       while ((mapdef != NULL)&&
+                               (mapdef = strtok(mapdef,TOKEN_DELIMITERS)) != NULL ) {
+                               i = LookForPart(SA,"charmap",mapdef);
+                               if ( i == INT_MAX ) {
+                                       //               cerr << "Unknown KEYMAP " << mapdef << endl;
+                                       printm(0, FALSE, MSG_KEYUNKNOWNMAP, mapdef);
+                               } else {
+                                       mapdef = strtok(NULL,"\n"); // strtok is used in LoadKeyMap
+                                       // so - save pointer!
+                                       if (LoadCharMap(SA[i])) // load it
+                                               SuccesLoaded++;
+                               };
+                       };
+                       if (!SuccesLoaded) {
+                               //            cerr << "No charmaps loaded\n";
+                               printm(0, FALSE, MSG_KEYNOCHARMAPS);
+                               Charmap.init();
+                       };
+                       /*         strtok(buf," ");
+                       
+                         char* name = strtok(NULL," ");
+                         if ( name == NULL ) {
+                         cerr << "No name for CHARMAP" << endl;
+                         } else {
+                         i = LookForPart(SA,"charmap", name);
+                         if ( i == INT_MAX ) {
+                         cerr << "Unknown CHARMAP " << name << endl;
+                         } else {
+                         LoadCharMap(SA[i]);
+                         };
+                         };
+                       */
+               }
+               else {
+                       //        cerr << "unexpected token in " << szActiveEmul << endl;
+                       printm(0, FALSE, MSG_KEYUNEXPTOKIN, szActiveEmul);
+               }
+       }
+
+       if ( hadKeys) {
+               TKeyDef empty;
+               KeyTrans.switchMap(empty); // switch to default
+               KeyTrans.mainKeyMap = KeyTrans.currentKeyMap; // save it's number
+               //     cerr << "There are " << (KeyTrans.mapArray.GetItemsInContainer()) << " maps\n";
+               char s[12]; // good enough for a long int (32-bit)
+               itoa(KeyTrans.mapArray.GetItemsInContainer(), s, 10);
+               printm(0, FALSE, MSG_KEYNUMMAPS, s);
+               return 1;
+       };
+       return 0;
+}
+
+void TMapLoader::Display() {
+
+    int max = KeyTrans.mapArray.GetItemsInContainer();
+    if (max == 0) {
+       printm(0, FALSE, MSG_KEYNOKEYMAPS);
+       return;
+    };
+    for ( int i = 0; i < max; i++ ) {
+       char buf[20];
+       itoa(i,buf,10);
+       printit("\t");
+       // Ioannou : we can show the current
+       if (KeyTrans.currentKeyMap == i)
+         printit("*");
+       else
+         printit(" ");
+       strcat(buf," ");
+       printit(buf);
+       char * msg = new char [KeyTrans.mapArray[i].orig.length()+1];
+       strcpy(msg,KeyTrans.mapArray[i].orig.c_str());
+       printit(msg);
+       delete[] msg;
+       printit("\n");
+    };
+};
diff --git a/rosapps/net/telnet/src/tmapldr.h b/rosapps/net/telnet/src/tmapldr.h
new file mode 100644 (file)
index 0000000..9f5a4aa
--- /dev/null
@@ -0,0 +1,105 @@
+///////////////////////////////////////////////////////////////////
+//                                                               //
+// File format :                                                 //
+//                                                               //
+//  Comments with a ; in column 1                                //
+//  Empty Lines ignored                                          //
+//  The words are separated by a space, a tab, or a plus ("+")   //
+//                                                               //
+//  First a [GLOBAL] section :                                   //
+//   [GLOBAL]                                                    //
+//   VK_F1         112                                           //
+//   .                                                           //
+//   .                                                           //
+//   [END_GLOBAL]                                                //
+//                                                               //
+//   The GLOBAL section defines the names of the keys            //
+//   and the virtual key code they have.                         //
+//   If you repeat a name you'll overwrite the code.             //
+//   You can name the keys anything you like                     //
+//   The Virtual key nymber must be in Decimal                   //
+//   After the number you can put anything : it is ignored       //
+//   Here you must put ALL the keys you'll use in the            //
+//   other sections.                                             //
+//                                                               //
+//  Then the emulations sections :                               //
+//                                                               //
+//   [SCO_ANSI]                                                  //
+//                                                               //
+//   VK_F1                    \027[M or                          //
+//   VK_F1                    ^[[M   or                          //
+//   VK_F1 SHIFT              ^[[W  etc                          //
+//   .                                                           //
+//   .                                                           //
+//   [SCO_ANSI_END]                                              //
+//                                                               //
+//   There are three parts :                                     //
+//      a) the key name                                          //
+//      b) the shift state                                       //
+//         here you put compination of the words :               //
+//                                                               //
+//                RIGHT_ALT                                      //
+//                LEFT_ALT                                       //
+//                RIGHT_CTRL                                     //
+//                LEFT_CTRL                                      //
+//                SHIFT                                          //
+//                NUMLOCK                                        //
+//                SCROLLLOCK                                     //
+//                CAPSLOCK                                       //
+//                ENHANCED                                       //
+//                APP_KEY                                        //
+//      c) the assigned string :                                 //
+//         you can use the ^ for esc (^[ = 0x1b)                 //
+//                         \ and a three digit decimal number    //
+//                         (\027)                                //
+//         You can't use the NULL !!!                            //
+//         Also (for the moment) you can't use spaces            //
+//         in the string : everything after the 3rd word is      //