mirror of
https://github.com/reactos/reactos.git
synced 2025-02-20 15:35:04 +00:00
New Telnet Client
svn path=/trunk/; revision=2458
This commit is contained in:
parent
f0c5d1e87f
commit
c98929fa7e
57 changed files with 14191 additions and 0 deletions
139
rosapps/net/telnet/Makefile
Normal file
139
rosapps/net/telnet/Makefile
Normal file
|
@ -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
|
142
rosapps/net/telnet/Makefile.mingw
Normal file
142
rosapps/net/telnet/Makefile.mingw
Normal file
|
@ -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
|
261
rosapps/net/telnet/doc/00readme.avs
Normal file
261
rosapps/net/telnet/doc/00readme.avs
Normal file
|
@ -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
|
||||
|
||||
|
||||
|
||||
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.
|
||||
|
||||
|
24
rosapps/net/telnet/doc/bugs.txt
Normal file
24
rosapps/net/telnet/doc/bugs.txt
Normal file
|
@ -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".
|
239
rosapps/net/telnet/doc/changes.txt
Normal file
239
rosapps/net/telnet/doc/changes.txt
Normal file
|
@ -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
|
340
rosapps/net/telnet/doc/license.txt
Normal file
340
rosapps/net/telnet/doc/license.txt
Normal file
|
@ -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.
|
||||
|
||||
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.)
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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
|
||||
|
||||
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.
|
||||
|
187
rosapps/net/telnet/doc/options.txt
Normal file
187
rosapps/net/telnet/doc/options.txt
Normal file
|
@ -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.
|
280
rosapps/net/telnet/doc/readme.txt
Normal file
280
rosapps/net/telnet/doc/readme.txt
Normal file
|
@ -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>
|
22
rosapps/net/telnet/doc/ssh.txt
Normal file
22
rosapps/net/telnet/doc/ssh.txt
Normal file
|
@ -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.
|
108
rosapps/net/telnet/resource/tnmsg.h
Normal file
108
rosapps/net/telnet/resource/tnmsg.h
Normal file
|
@ -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
|
107
rosapps/net/telnet/resource/tnmsg.rc
Normal file
107
rosapps/net/telnet/resource/tnmsg.rc
Normal file
|
@ -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
|
1474
rosapps/net/telnet/src/ansiprsr.cpp
Normal file
1474
rosapps/net/telnet/src/ansiprsr.cpp
Normal file
File diff suppressed because it is too large
Load diff
85
rosapps/net/telnet/src/ansiprsr.h
Normal file
85
rosapps/net/telnet/src/ansiprsr.h
Normal file
|
@ -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
|
227
rosapps/net/telnet/src/keytrans.cpp
Normal file
227
rosapps/net/telnet/src/keytrans.cpp
Normal file
|
@ -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;
|
||||
};
|
97
rosapps/net/telnet/src/keytrans.h
Normal file
97
rosapps/net/telnet/src/keytrans.h
Normal file
|
@ -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
|
169
rosapps/net/telnet/src/stl_bids.h
Normal file
169
rosapps/net/telnet/src/stl_bids.h
Normal file
|
@ -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
|
220
rosapps/net/telnet/src/tcharmap.cpp
Normal file
220
rosapps/net/telnet/src/tcharmap.cpp
Normal file
|
@ -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;
|
||||
}
|
41
rosapps/net/telnet/src/tcharmap.h
Normal file
41
rosapps/net/telnet/src/tcharmap.h
Normal file
|
@ -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
|
1008
rosapps/net/telnet/src/tconsole.cpp
Normal file
1008
rosapps/net/telnet/src/tconsole.cpp
Normal file
File diff suppressed because it is too large
Load diff
172
rosapps/net/telnet/src/tconsole.h
Normal file
172
rosapps/net/telnet/src/tconsole.h
Normal file
|
@ -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
|
305
rosapps/net/telnet/src/telnet.h
Normal file
305
rosapps/net/telnet/src/telnet.h
Normal file
|
@ -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
|
||||
|
135
rosapps/net/telnet/src/tkeydef.cpp
Normal file
135
rosapps/net/telnet/src/tkeydef.cpp
Normal file
|
@ -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
|
||||
|
71
rosapps/net/telnet/src/tkeydef.h
Normal file
71
rosapps/net/telnet/src/tkeydef.h
Normal file
|
@ -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
|
62
rosapps/net/telnet/src/tkeymap.cpp
Normal file
62
rosapps/net/telnet/src/tkeymap.cpp
Normal file
|
@ -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() {
|
||||
};
|
39
rosapps/net/telnet/src/tkeymap.h
Normal file
39
rosapps/net/telnet/src/tkeymap.h
Normal file
|
@ -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
|
773
rosapps/net/telnet/src/tmapldr.cpp
Normal file
773
rosapps/net/telnet/src/tmapldr.cpp
Normal file
|
@ -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");
|
||||
};
|
||||
};
|
105
rosapps/net/telnet/src/tmapldr.h
Normal file
105
rosapps/net/telnet/src/tmapldr.h
Normal file
|
@ -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 //
|
||||
// ignored - use unsderscore instead. //
|
||||
// //
|
||||
// for example : //
|
||||
// //
|
||||
// VK_F4 SHIFT+LEFT_ALT \0274m^[[M = 0x1b 4 m 0x1b [ M //
|
||||
// VK_F1 RIGHT_CTRL This_is_ctrl_f1 //
|
||||
// //
|
||||
// You may have as many sections as you like //
|
||||
// If you repeat any section (even the GLOBAL) you'll overwrite //
|
||||
// the common parts. //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __TLOADMAP_H
|
||||
#define __TLOADMAP_H
|
||||
|
||||
#include "keytrans.h"
|
||||
#include "tcharmap.h"
|
||||
|
||||
// AVS
|
||||
typedef TArrayAsVector<string> stringArray;
|
||||
|
||||
class TMapLoader {
|
||||
public:
|
||||
TMapLoader(KeyTranslator &RefKeyTrans, TCharmap &RefCharmap):
|
||||
KeyTrans(RefKeyTrans), Charmap(RefCharmap) {}
|
||||
~TMapLoader() {}
|
||||
|
||||
// If called more than once the new map replaces the old one.
|
||||
// load with a different KeysetName to change keysets
|
||||
// Return 0 on error
|
||||
int Load(const char * filename, const char * szKeysetName);
|
||||
|
||||
void Display();
|
||||
private:
|
||||
KeyTranslator &KeyTrans;
|
||||
TCharmap &Charmap;
|
||||
|
||||
int LookForPart(stringArray& sa, const char* partType, const char* partName);
|
||||
char* ParseKeyDef(const char* buf, WORD& vk_code, DWORD& control);
|
||||
|
||||
int LoadGlobal(string& buf);
|
||||
int LoadKeyMap(string buf);
|
||||
int LoadCharMap(string buf);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
210
rosapps/net/telnet/src/tmouse.cpp
Normal file
210
rosapps/net/telnet/src/tmouse.cpp
Normal file
|
@ -0,0 +1,210 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
//Telnet Win32 : an ANSI telnet client.
|
||||
//Copyright (C) 1998 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
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// TMouse.cpp
|
||||
// A simple class for handling mouse events
|
||||
// Written by Paul Brannan <pbranna@clemson.edu>
|
||||
// Last modified August 30, 1998
|
||||
|
||||
#include "tmouse.h"
|
||||
#include "tconsole.h"
|
||||
|
||||
TMouse::TMouse(Tnclip &RefClipboard): Clipboard(RefClipboard) {
|
||||
hConsole = GetStdHandle(STD_INPUT_HANDLE);
|
||||
hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
}
|
||||
|
||||
TMouse::~TMouse() {
|
||||
}
|
||||
|
||||
void TMouse::get_coords(COORD *start_coords, COORD *end_coords,
|
||||
COORD *first_coords, COORD *last_coords) {
|
||||
if(end_coords->Y < start_coords->Y ||
|
||||
(end_coords->Y == start_coords->Y && end_coords->X < start_coords->X))
|
||||
{
|
||||
*first_coords = *end_coords;
|
||||
*last_coords = *start_coords;
|
||||
} else {
|
||||
*first_coords = *start_coords;
|
||||
*last_coords = *end_coords;
|
||||
}
|
||||
last_coords->X++;
|
||||
}
|
||||
|
||||
void TMouse::doMouse_init() {
|
||||
GetConsoleScreenBufferInfo(hStdout, &ConsoleInfo);
|
||||
chiBuffer = newBuffer();
|
||||
saveScreen(chiBuffer);
|
||||
}
|
||||
|
||||
void TMouse::doMouse_cleanup() {
|
||||
restoreScreen(chiBuffer);
|
||||
delete[] chiBuffer;
|
||||
}
|
||||
|
||||
void TMouse::move_mouse(COORD start_coords, COORD end_coords) {
|
||||
COORD screen_start = {0, 0};
|
||||
COORD first_coords, last_coords;
|
||||
DWORD Result;
|
||||
|
||||
FillConsoleOutputAttribute(hStdout, normal,
|
||||
ConsoleInfo.dwSize.X * ConsoleInfo.dwSize.Y, screen_start, &Result);
|
||||
|
||||
get_coords(&start_coords, &end_coords, &first_coords, &last_coords);
|
||||
FillConsoleOutputAttribute(hStdout, inverse, ConsoleInfo.dwSize.X *
|
||||
(last_coords.Y - first_coords.Y) + (last_coords.X - first_coords.X),
|
||||
first_coords, &Result);
|
||||
}
|
||||
|
||||
void TMouse::doClip(COORD start_coords, COORD end_coords) {
|
||||
// COORD screen_start = {0, 0};
|
||||
COORD first_coords, last_coords;
|
||||
DWORD Result;
|
||||
|
||||
get_coords(&start_coords, &end_coords, &first_coords, &last_coords);
|
||||
|
||||
// Allocate the minimal size buffer
|
||||
int data_size = 3 + ConsoleInfo.dwSize.X *
|
||||
(last_coords.Y - first_coords.Y) + (last_coords.X - first_coords.X);
|
||||
HGLOBAL clipboard_data = GlobalAlloc(GMEM_MOVEABLE + GMEM_DDESHARE,
|
||||
data_size);
|
||||
LPVOID mem_ptr = GlobalLock(clipboard_data);
|
||||
|
||||
// Reset data_size so we can count the actual data size
|
||||
data_size = 0;
|
||||
|
||||
// Read the console, put carriage returns at the end of each line if
|
||||
// reading more than one line (Paul Brannan 9/17/98)
|
||||
for(int j = first_coords.Y; j <= last_coords.Y; j++) {
|
||||
|
||||
// Read line at (0,j)
|
||||
COORD coords;
|
||||
coords.X = 0;
|
||||
coords.Y = j;
|
||||
int length = ConsoleInfo.dwSize.X;
|
||||
|
||||
if(j == first_coords.Y) {
|
||||
coords.X = first_coords.X;
|
||||
length = ConsoleInfo.dwSize.X - first_coords.X;
|
||||
} else {
|
||||
// Add a carriage return to the end of the previous line
|
||||
*((char *)mem_ptr + data_size++) = '\r';
|
||||
*((char *)mem_ptr + data_size++) = '\n';
|
||||
}
|
||||
|
||||
if(j == last_coords.Y) {
|
||||
length -= (ConsoleInfo.dwSize.X - last_coords.X);
|
||||
}
|
||||
|
||||
// Read the next line
|
||||
ReadConsoleOutputCharacter(hStdout, (LPTSTR)((char *)mem_ptr +
|
||||
data_size), length, coords, &Result);
|
||||
data_size += Result;
|
||||
|
||||
// Strip the spaces at the end of the line
|
||||
if((j != last_coords.Y) && (first_coords.Y != last_coords.Y))
|
||||
while(*((char *)mem_ptr + data_size - 1) == ' ') data_size--;
|
||||
}
|
||||
if(first_coords.Y != last_coords.Y) {
|
||||
// Add a carriage return to the end of the last line
|
||||
*((char *)mem_ptr + data_size++) = '\r';
|
||||
*((char *)mem_ptr + data_size++) = '\n';
|
||||
}
|
||||
|
||||
*((char *)mem_ptr + data_size) = 0;
|
||||
GlobalUnlock(clipboard_data);
|
||||
|
||||
Clipboard.Copy(clipboard_data);
|
||||
}
|
||||
|
||||
void TMouse::doMouse() {
|
||||
INPUT_RECORD InputRecord;
|
||||
DWORD Result;
|
||||
InputRecord.EventType = KEY_EVENT; // just in case
|
||||
while(InputRecord.EventType != MOUSE_EVENT) {
|
||||
if (!ReadConsoleInput(hConsole, &InputRecord, 1, &Result))
|
||||
return; // uh oh! we don't know the starting coordinates!
|
||||
}
|
||||
if(InputRecord.Event.MouseEvent.dwButtonState == 0) return;
|
||||
if(!(InputRecord.Event.MouseEvent.dwButtonState &
|
||||
FROM_LEFT_1ST_BUTTON_PRESSED)) {
|
||||
Clipboard.Paste();
|
||||
return;
|
||||
}
|
||||
|
||||
COORD screen_start = {0, 0};
|
||||
COORD start_coords = InputRecord.Event.MouseEvent.dwMousePosition;
|
||||
COORD end_coords = start_coords;
|
||||
BOOL done = FALSE;
|
||||
|
||||
// init vars
|
||||
doMouse_init();
|
||||
int normal_bg = ini.get_normal_bg();
|
||||
int normal_fg = ini.get_normal_fg();
|
||||
if(normal_bg == -1) normal_bg = 0; // FIX ME!! This is just a hack
|
||||
if(normal_fg == -1) normal_fg = 7;
|
||||
normal = (normal_bg << 4) | normal_fg;
|
||||
inverse = (normal_fg << 4) | normal_bg;
|
||||
|
||||
// make screen all one attribute
|
||||
FillConsoleOutputAttribute(hStdout, normal, ConsoleInfo.dwSize.X *
|
||||
ConsoleInfo.dwSize.Y, screen_start, &Result);
|
||||
|
||||
while(!done) {
|
||||
|
||||
switch (InputRecord.EventType) {
|
||||
case MOUSE_EVENT:
|
||||
switch(InputRecord.Event.MouseEvent.dwEventFlags) {
|
||||
case 0: // only copy if the mouse button has been released
|
||||
if(!InputRecord.Event.MouseEvent.dwButtonState) {
|
||||
doClip(start_coords, end_coords);
|
||||
done = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case MOUSE_MOVED:
|
||||
end_coords = InputRecord.Event.MouseEvent.dwMousePosition;
|
||||
move_mouse(start_coords, end_coords);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
// If we are changing focus, we don't want to highlight anything
|
||||
// (Paul Brannan 9/2/98)
|
||||
case FOCUS_EVENT:
|
||||
return;
|
||||
}
|
||||
|
||||
WaitForSingleObject(hConsole, INFINITE);
|
||||
if (!ReadConsoleInput(hConsole, &InputRecord, 1, &Result))
|
||||
done = TRUE;
|
||||
|
||||
}
|
||||
|
||||
doMouse_cleanup();
|
||||
}
|
||||
|
||||
void TMouse::scrollMouse() {
|
||||
doMouse();
|
||||
}
|
29
rosapps/net/telnet/src/tmouse.h
Normal file
29
rosapps/net/telnet/src/tmouse.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
#ifndef __TMOUSE_H
|
||||
#define __TMOUSE_H
|
||||
|
||||
#include "tnclip.h"
|
||||
#include <windows.h>
|
||||
|
||||
class TMouse {
|
||||
private:
|
||||
int normal, inverse;
|
||||
HANDLE hConsole, hStdout;
|
||||
CHAR_INFO *chiBuffer;
|
||||
CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo;
|
||||
Tnclip &Clipboard;
|
||||
|
||||
void get_coords(COORD *start_coords, COORD *end_coords,
|
||||
COORD *first_coords, COORD *last_coords);
|
||||
void doMouse_init();
|
||||
void doMouse_cleanup();
|
||||
void move_mouse(COORD start_coords, COORD end_coords);
|
||||
void doClip(COORD start_coords, COORD end_coords);
|
||||
|
||||
public:
|
||||
void doMouse();
|
||||
void scrollMouse();
|
||||
TMouse(Tnclip &RefClipboard);
|
||||
~TMouse();
|
||||
};
|
||||
|
||||
#endif
|
398
rosapps/net/telnet/src/tnclass.cpp
Normal file
398
rosapps/net/telnet/src/tnclass.cpp
Normal file
|
@ -0,0 +1,398 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
//Telnet Win32 : an ANSI telnet client.
|
||||
//Copyright (C) 1998 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: tnclass.cpp
|
||||
//
|
||||
// Contents: telnet object definition
|
||||
//
|
||||
// Product: telnet
|
||||
//
|
||||
// Revisions: August 30, 1998 Paul Brannan <pbranna@clemson.edu>
|
||||
// July 12, 1998 Paul Brannan
|
||||
// June 15, 1998 Paul Brannan
|
||||
// May 14, 1998 Paul Brannan
|
||||
// 5.April.1997 jbj@nounname.com
|
||||
// 14.Sept.1996 jbj@nounname.com
|
||||
// Version 2.0
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "tnclass.h"
|
||||
#include "tnmisc.h"
|
||||
|
||||
// Mingw32 needs these (Paul Brannan 9/4/98)
|
||||
#ifndef ICON_SMALL
|
||||
#define ICON_SMALL 0
|
||||
#endif
|
||||
#ifndef ICON_BIG
|
||||
#define ICON_BIG 1
|
||||
#endif
|
||||
|
||||
// Ioannou Dec. 8, 1998
|
||||
#ifdef __BORLANDC__
|
||||
#ifndef WM_SETICON
|
||||
#define WM_SETICON STM_SETICON
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// DoInit() - performs initialization that is common to both the
|
||||
// constructors (Paul Brannan 6/15/98)
|
||||
void Telnet::DoInit() {
|
||||
Socket = INVALID_SOCKET;
|
||||
bConnected = 0;
|
||||
bNetPaused = 1;
|
||||
bNetFinished = 1;
|
||||
bNetFinish = 0;
|
||||
hThread = 0; // Sam Robertson 12/7/98
|
||||
hProcess = 0;
|
||||
|
||||
WSADATA WsaData;
|
||||
|
||||
// Set the title
|
||||
telSetConsoleTitle("No Connection");
|
||||
|
||||
// Change the icon
|
||||
hConsoleWindow = GetConsoleWindow();
|
||||
iconChange = SetIcon(hConsoleWindow, 0, &oldBIcon, &oldSIcon, ini.get_startdir());
|
||||
|
||||
if (WSAStartup(MAKEWORD(1, 1), &WsaData)) {
|
||||
DWORD dwLastError = GetLastError();
|
||||
printm(0, FALSE, MSG_ERROR, "WSAStartup()");
|
||||
printm(0, TRUE, dwLastError);
|
||||
bWinsockUp = 0;
|
||||
return;
|
||||
}
|
||||
bWinsockUp = 1;
|
||||
|
||||
// Get keyfile (Paul Brannan 5/12/98)
|
||||
const char *keyfile = ini.get_keyfile();
|
||||
|
||||
// This should be changed later to use the Tnerror routines
|
||||
// This has been done (Paul Brannan 6/5/98)
|
||||
if(LoadKeyMap( keyfile, ini.get_default_config()) != 1)
|
||||
// printf("Error loading keymap.\n");
|
||||
printm(0, FALSE, MSG_ERRKEYMAP);
|
||||
}
|
||||
|
||||
Telnet::Telnet():
|
||||
MapLoader(KeyTrans, Charmap),
|
||||
Console(GetStdHandle(STD_OUTPUT_HANDLE)),
|
||||
TelHandler(Network, Console, Parser),
|
||||
ThreadParams(TelHandler),
|
||||
Clipboard(GetConsoleWindow(), Network),
|
||||
Mouse(Clipboard),
|
||||
Scroller(Mouse, ini.get_scroll_size()),
|
||||
Parser(Console, KeyTrans, Scroller, Network, Charmap) {
|
||||
DoInit();
|
||||
}
|
||||
|
||||
Telnet::Telnet(const char * szHost1, const char *strPort1):
|
||||
MapLoader(KeyTrans, Charmap),
|
||||
Console(GetStdHandle(STD_OUTPUT_HANDLE)),
|
||||
TelHandler(Network, Console, Parser),
|
||||
ThreadParams(TelHandler),
|
||||
Clipboard(GetConsoleWindow(), Network),
|
||||
Mouse(Clipboard),
|
||||
Scroller(Mouse, ini.get_scroll_size()),
|
||||
Parser(Console, KeyTrans, Scroller, Network, Charmap) {
|
||||
DoInit();
|
||||
Open( szHost1, strPort1);
|
||||
}
|
||||
|
||||
Telnet::~Telnet(){
|
||||
if (bWinsockUp){
|
||||
if(bConnected) Close();
|
||||
WSACleanup();
|
||||
}
|
||||
|
||||
// Paul Brannan 8/10/98
|
||||
if(iconChange) {
|
||||
ResetIcon(hConsoleWindow, oldBIcon, oldSIcon);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// changed from char * to const char * (Paul Brannan 5/12/98)
|
||||
int Telnet::LoadKeyMap(const char * file, const char * name){
|
||||
// printf("Loading %s from %s.\n", name ,file);
|
||||
printm(0, FALSE, MSG_KEYMAP, name, file);
|
||||
return MapLoader.Load(file,name);
|
||||
}
|
||||
|
||||
void Telnet::DisplayKeyMap(){ // display available keymaps
|
||||
MapLoader.Display();
|
||||
};
|
||||
|
||||
int Telnet::SwitchKeyMap(int to) { // switch to selected keymap
|
||||
int ret = KeyTrans.SwitchTo(to);
|
||||
switch(ret) {
|
||||
case -1: printm(0, FALSE, MSG_KEYNOKEYMAPS); break;
|
||||
case 0: printm(0, FALSE, MSG_KEYBADMAP); break;
|
||||
case 1: printm(0, FALSE, MSG_KEYMAPSWITCHED); break;
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
|
||||
int Telnet::Open(const char *szHost1, const char *strPort1){
|
||||
if (bWinsockUp && !bConnected){
|
||||
telSetConsoleTitle(szHost1);
|
||||
|
||||
strncpy (szHost,szHost1, 127);
|
||||
strncpy(strPort, strPort1, sizeof(strPort));
|
||||
|
||||
// Determine whether to pipe to an executable or use our own sockets
|
||||
// (Paul Brannan March 18, 1999)
|
||||
const char *netpipe;
|
||||
if(*(netpipe=ini.get_netpipe())) {
|
||||
PROCESS_INFORMATION pi;
|
||||
HANDLE hInWrite, hOutRead, hErrRead;
|
||||
if(!CreateHiddenConsoleProcess(netpipe, &pi, &hInWrite,
|
||||
&hOutRead, &hErrRead)) {
|
||||
printm(0, FALSE, MSG_ERRPIPE);
|
||||
return TNNOCON;
|
||||
}
|
||||
Network.SetPipe(hOutRead, hInWrite);
|
||||
hProcess = pi.hProcess;
|
||||
} else {
|
||||
Socket = Connect();
|
||||
if (Socket == INVALID_SOCKET) {
|
||||
printm(0, FALSE, GetLastError());
|
||||
return TNNOCON;
|
||||
}
|
||||
Network.SetSocket(Socket);
|
||||
SetLocalAddress(Socket);
|
||||
}
|
||||
|
||||
bNetFinish = 0;
|
||||
bConnected = 1;
|
||||
ThreadParams.p.bNetPaused = &bNetPaused;
|
||||
ThreadParams.p.bNetFinish = &bNetFinish;
|
||||
ThreadParams.p.bNetFinished = &bNetFinished;
|
||||
ThreadParams.p.hExit = CreateEvent(0, TRUE, FALSE, "");
|
||||
ThreadParams.p.hPause = CreateEvent(0, FALSE, FALSE, "");
|
||||
ThreadParams.p.hUnPause = CreateEvent(0, FALSE, FALSE, "");
|
||||
DWORD idThread;
|
||||
|
||||
// Disable Ctrl-break (PB 5/14/98);
|
||||
// Fixed (Thomas Briggs 8/17/98)
|
||||
if(ini.get_disable_break() || ini.get_control_break_as_c())
|
||||
SetConsoleCtrlHandler(ControlEventHandler, TRUE);
|
||||
|
||||
hThread = CreateThread(0, 0,
|
||||
(LPTHREAD_START_ROUTINE) telProcessNetwork,
|
||||
(LPVOID)&ThreadParams, 0, &idThread);
|
||||
// This helps the display thread a little (Paul Brannan 8/3/98)
|
||||
SetThreadPriority(hThread, THREAD_PRIORITY_ABOVE_NORMAL);
|
||||
return Resume();
|
||||
} else if(bWinsockUp && bConnected) {
|
||||
printm (0, FALSE, MSG_ALREADYCONNECTED, szHost);
|
||||
}
|
||||
|
||||
return TNNOCON; // cannot do winsock stuff or already connected
|
||||
}
|
||||
|
||||
// There seems to be a bug with MSVC's optimization. This turns them off
|
||||
// for these two functions.
|
||||
// (Paul Brannan 5/14/98)
|
||||
#ifdef _MSC_VER
|
||||
#pragma optimize("", off)
|
||||
#endif
|
||||
|
||||
|
||||
int Telnet::Close() {
|
||||
Console.sync();
|
||||
switch(Network.get_net_type()) {
|
||||
case TN_NETSOCKET:
|
||||
if(Socket != INVALID_SOCKET) closesocket(Socket);
|
||||
Socket = INVALID_SOCKET;
|
||||
break;
|
||||
case TN_NETPIPE:
|
||||
if(hProcess != 0) {
|
||||
TerminateProcess(hProcess, 0);
|
||||
CloseHandle(hProcess);
|
||||
hProcess = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Enable Ctrl-break (PB 5/14/98);
|
||||
// Ioannou : this must be FALSE
|
||||
if(ini.get_disable_break()) SetConsoleCtrlHandler(NULL, FALSE);
|
||||
|
||||
if (hThread) CloseHandle(hThread); // Paul Brannan 8/11/98
|
||||
hThread = NULL; // Daniel Straub 11/12/98
|
||||
|
||||
SetEvent(ThreadParams.p.hUnPause);
|
||||
bNetFinish = 1;
|
||||
while (!bNetFinished)
|
||||
Sleep (0); // give up our time slice- this lets our connection thread
|
||||
// finish itself, so we don't hang -crn@ozemail.com.au
|
||||
telSetConsoleTitle("No Connection");
|
||||
bConnected = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Telnet::Resume(){
|
||||
int i;
|
||||
if (bConnected) {
|
||||
Console.sync();
|
||||
for(;;){
|
||||
SetEvent(ThreadParams.p.hUnPause);
|
||||
i = telProcessConsole(&ThreadParams.p, KeyTrans, Console,
|
||||
Network, Mouse, Clipboard, hThread);
|
||||
if (i) bConnected = 1;
|
||||
else bConnected = 0;
|
||||
ResetEvent(ThreadParams.p.hUnPause);
|
||||
SetEvent(ThreadParams.p.hPause);
|
||||
while (!bNetPaused)
|
||||
Sleep (0); // give up our time slice- this lets our connection thread
|
||||
// unpause itself, so we don't hang -crn@ozemail.com.au
|
||||
switch (i){
|
||||
case TNNOCON:
|
||||
Close();
|
||||
return TNDONE;
|
||||
case TNPROMPT:
|
||||
return TNPROMPT;
|
||||
case TNSCROLLBACK:
|
||||
Scroller.ScrollBack();
|
||||
break;
|
||||
case TNSPAWN:
|
||||
NewProcess();
|
||||
}
|
||||
}
|
||||
}
|
||||
return TNNOCON;
|
||||
}
|
||||
|
||||
// Turn optimization back on (Paul Brannan 5/12/98)
|
||||
#ifdef _MSC_VER
|
||||
#pragma optimize("", on)
|
||||
#endif
|
||||
|
||||
// The scrollback functions have been moved to TScroll.cpp
|
||||
// (Paul Brannan 6/15/98)
|
||||
SOCKET Telnet::Connect()
|
||||
{
|
||||
SOCKET Socket1 = socket(AF_INET, SOCK_STREAM, 0);
|
||||
SOCKADDR_IN SockAddr;
|
||||
SockAddr.sin_family = AF_INET;
|
||||
SockAddr.sin_addr.s_addr = inet_addr(szHost);
|
||||
|
||||
// determine the port correctly -crn@ozemail.com.au 15/12/98
|
||||
SERVENT *sp;
|
||||
sp = getservbyname (strPort, "tcp");
|
||||
if (sp == NULL) {
|
||||
if (isdigit (*(strPort)))
|
||||
SockAddr.sin_port = htons(atoi(strPort));
|
||||
else {
|
||||
printm(0, FALSE, MSG_NOSERVICE, strPort);
|
||||
return INVALID_SOCKET;
|
||||
}
|
||||
} else
|
||||
SockAddr.sin_port = sp->s_port;
|
||||
///
|
||||
|
||||
// Were we given host name?
|
||||
if (SockAddr.sin_addr.s_addr == INADDR_NONE) {
|
||||
|
||||
// Resolve host name to IP address.
|
||||
printm(0, FALSE, MSG_RESOLVING, szHost);
|
||||
hostent* pHostEnt = gethostbyname(szHost);
|
||||
if (!pHostEnt)
|
||||
return INVALID_SOCKET;
|
||||
printit("\n");
|
||||
|
||||
SockAddr.sin_addr.s_addr = *(DWORD*)pHostEnt->h_addr;
|
||||
}
|
||||
|
||||
// Print a message telling the user the IP we are connecting to
|
||||
// (Paul Brannan 5/14/98)
|
||||
char ss_b1[4], ss_b2[4], ss_b3[4], ss_b4[4], ss_b5[12];
|
||||
itoa(SockAddr.sin_addr.S_un.S_un_b.s_b1, ss_b1, 10);
|
||||
itoa(SockAddr.sin_addr.S_un.S_un_b.s_b2, ss_b2, 10);
|
||||
itoa(SockAddr.sin_addr.S_un.S_un_b.s_b3, ss_b3, 10);
|
||||
itoa(SockAddr.sin_addr.S_un.S_un_b.s_b4, ss_b4, 10);
|
||||
itoa(ntohs(SockAddr.sin_port), ss_b5, 10);
|
||||
printm(0, FALSE, MSG_TRYING, ss_b1, ss_b2, ss_b3, ss_b4, ss_b5);
|
||||
|
||||
if (connect(Socket1, (sockaddr*)&SockAddr, sizeof(SockAddr)))
|
||||
return INVALID_SOCKET;
|
||||
|
||||
char esc[2];
|
||||
esc [0] = ini.get_escape_key();
|
||||
esc [1] = 0;
|
||||
printm(0, FALSE, MSG_CONNECTED, szHost, esc);
|
||||
|
||||
return Socket1;
|
||||
}
|
||||
|
||||
void Telnet::telSetConsoleTitle(const char * szHost1)
|
||||
{
|
||||
char szTitle[128] = "Telnet - ";
|
||||
strcat(szTitle, szHost1);
|
||||
if(ini.get_set_title()) SetConsoleTitle(szTitle);
|
||||
}
|
||||
|
||||
void Telnet::NewProcess() {
|
||||
char cmd_line[MAX_PATH*2];
|
||||
PROCESS_INFORMATION pi;
|
||||
|
||||
strcpy(cmd_line, ini.get_startdir());
|
||||
strcat(cmd_line, ini.get_exename()); // Thomas Briggs 12/7/98
|
||||
|
||||
if(!SpawnProcess(cmd_line, &pi)) printm(0, FALSE, MSG_NOSPAWN);
|
||||
}
|
||||
|
||||
void Telnet::SetLocalAddress(SOCKET s) {
|
||||
SOCKADDR_IN SockAddr;
|
||||
int size = sizeof(SOCKADDR_IN);
|
||||
memset(&SockAddr, 0, sizeof(SockAddr));
|
||||
SockAddr.sin_family = AF_INET;
|
||||
|
||||
getsockname(Network.GetSocket(), (sockaddr*)&SockAddr, &size);
|
||||
char ss_b1[4], ss_b2[4], ss_b3[4], ss_b4[4];
|
||||
itoa(SockAddr.sin_addr.S_un.S_un_b.s_b1, ss_b1, 10);
|
||||
itoa(SockAddr.sin_addr.S_un.S_un_b.s_b2, ss_b2, 10);
|
||||
itoa(SockAddr.sin_addr.S_un.S_un_b.s_b3, ss_b3, 10);
|
||||
itoa(SockAddr.sin_addr.S_un.S_un_b.s_b4, ss_b4, 10);
|
||||
|
||||
char addr[40];
|
||||
strcpy(addr, ss_b1);
|
||||
strcat(addr, ".");
|
||||
strcat(addr, ss_b2);
|
||||
strcat(addr, ".");
|
||||
strcat(addr, ss_b3);
|
||||
strcat(addr, ".");
|
||||
strcat(addr, ss_b4);
|
||||
strcat(addr, ":0.0");
|
||||
|
||||
Network.SetLocalAddress(addr);
|
||||
}
|
||||
|
73
rosapps/net/telnet/src/tnclass.h
Normal file
73
rosapps/net/telnet/src/tnclass.h
Normal file
|
@ -0,0 +1,73 @@
|
|||
#ifndef __TNCLASS_H_
|
||||
#define __TNCLASS_H_
|
||||
|
||||
#include <windows.h>
|
||||
#include "tnconfig.h"
|
||||
#include "ttelhndl.h"
|
||||
#include "tncon.h"
|
||||
#include "tnerror.h"
|
||||
#include "tparams.h"
|
||||
#include "keytrans.h"
|
||||
#include "ansiprsr.h"
|
||||
#include "tcharmap.h"
|
||||
#include "tnclip.h"
|
||||
#include "tmouse.h"
|
||||
#include "tmapldr.h"
|
||||
|
||||
class Telnet {
|
||||
public:
|
||||
// create a telnet instance
|
||||
Telnet();
|
||||
// open a connection return on break/quit
|
||||
Telnet(const char * szHost1, const char *strPort1);
|
||||
~Telnet();
|
||||
|
||||
// open a connection return on break/quit
|
||||
int Open(const char *szHost, const char *strPort = "23");
|
||||
int Close(); // close current connection
|
||||
int Resume(); // resume current session
|
||||
|
||||
// changes to the keymap profile in the file
|
||||
int LoadKeyMap( const char * file, const char * name);
|
||||
void DisplayKeyMap(); // display available keymaps
|
||||
int SwitchKeyMap(int); // switch to selected keymap
|
||||
private:
|
||||
SOCKET Connect();
|
||||
void telSetConsoleTitle(const char * szHost);
|
||||
void DoInit();
|
||||
|
||||
SOCKET Socket;
|
||||
char strPort[32]; // int iPort;
|
||||
char szHost[127];
|
||||
volatile int bConnected;
|
||||
volatile int bWinsockUp;
|
||||
volatile int bNetPaused;
|
||||
volatile int bNetFinished;
|
||||
volatile int bNetFinish;
|
||||
|
||||
// The order of member classes in the class definition MUST come in
|
||||
// this order! (Paul Brannan 12/4/98)
|
||||
TNetwork Network;
|
||||
TCharmap Charmap;
|
||||
KeyTranslator KeyTrans;
|
||||
TMapLoader MapLoader;
|
||||
TConsole Console;
|
||||
TTelnetHandler TelHandler;
|
||||
TelThreadParams ThreadParams;
|
||||
Tnclip Clipboard;
|
||||
TMouse Mouse;
|
||||
TScroller Scroller;
|
||||
TANSIParser Parser;
|
||||
|
||||
HWND hConsoleWindow; // Paul Brannan 8/10/98
|
||||
LPARAM oldBIcon, oldSIcon; // Paul Brannan 8/10/98
|
||||
bool iconChange;
|
||||
|
||||
HANDLE hThread; // Paul Brannan 8/11/98
|
||||
HANDLE hProcess; // Paul Brannan 7/15/99
|
||||
|
||||
void NewProcess(); // Paul Brannan 9/13/98
|
||||
void SetLocalAddress(SOCKET s);
|
||||
};
|
||||
|
||||
#endif
|
59
rosapps/net/telnet/src/tnclip.cpp
Normal file
59
rosapps/net/telnet/src/tnclip.cpp
Normal file
|
@ -0,0 +1,59 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
//Telnet Win32 : an ANSI telnet client.
|
||||
//Copyright (C) 1998 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
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// TnClip.cpp
|
||||
// A simple class for handling clipboard functions
|
||||
// Written by Paul Brannan <pbranna@clemson.edu>
|
||||
// Last modified 7/12/98
|
||||
|
||||
#include <string.h>
|
||||
#include "tnclip.h"
|
||||
|
||||
Tnclip::Tnclip(HWND W, TNetwork &RefNetwork): Network(RefNetwork) {
|
||||
Window = W;
|
||||
}
|
||||
|
||||
Tnclip::~Tnclip() {
|
||||
}
|
||||
|
||||
void Tnclip::Copy(HGLOBAL clipboard_data) {
|
||||
if(!OpenClipboard(Window)) return;
|
||||
if(!EmptyClipboard()) return;
|
||||
|
||||
SetClipboardData(CF_TEXT, clipboard_data);
|
||||
CloseClipboard();
|
||||
}
|
||||
|
||||
void Tnclip::Paste() {
|
||||
if(!OpenClipboard(Window)) return;
|
||||
|
||||
HANDLE clipboard_data = GetClipboardData(CF_TEXT);
|
||||
LPVOID clipboard_ptr = GlobalLock(clipboard_data);
|
||||
DWORD size = strlen((const char *)clipboard_data);
|
||||
Network.WriteString((const char *)clipboard_ptr, size);
|
||||
GlobalUnlock(clipboard_data);
|
||||
|
||||
CloseClipboard();
|
||||
}
|
20
rosapps/net/telnet/src/tnclip.h
Normal file
20
rosapps/net/telnet/src/tnclip.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef __TNCLIP_H
|
||||
#define __TNCLIP_H
|
||||
|
||||
#include <windows.h>
|
||||
#include "tnetwork.h"
|
||||
|
||||
class Tnclip {
|
||||
private:
|
||||
HWND Window;
|
||||
TNetwork &Network;
|
||||
|
||||
public:
|
||||
Tnclip(HWND Window, TNetwork &RefNetwork);
|
||||
~Tnclip();
|
||||
|
||||
void Copy(HGLOBAL clipboard_data);
|
||||
void Paste();
|
||||
};
|
||||
|
||||
#endif
|
368
rosapps/net/telnet/src/tncon.cpp
Normal file
368
rosapps/net/telnet/src/tncon.cpp
Normal file
|
@ -0,0 +1,368 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
//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: tncon.cpp
|
||||
//
|
||||
// Contents: telnet console processing
|
||||
//
|
||||
// Product: telnet
|
||||
//
|
||||
// Revisions: August 30, 1998 Paul Brannan <pbranna@clemson.edu>
|
||||
// July 29, 1998 Paul Brannan
|
||||
// June 15, 1998 Paul Brannan
|
||||
// May 16, 1998 Paul Brannan
|
||||
// 5.April.1997 jbj@nounname.com
|
||||
// 9.Dec.1996 jbj@nounname.com
|
||||
// Version 2.0
|
||||
//
|
||||
// 02.Apr.1995 igor.milavec@uni-lj.si
|
||||
// Original code
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#include "tncon.h"
|
||||
#include "keytrans.h"
|
||||
#include "ttelhndl.h"
|
||||
#include "tconsole.h"
|
||||
|
||||
#define KEYEVENT InputRecord[i].Event.KeyEvent
|
||||
|
||||
// Paul Brannan 6/25/98
|
||||
// #ifdef __MINGW32__
|
||||
// #define KEYEVENT_CHAR KEYEVENT.AsciiChar
|
||||
// #else
|
||||
#define KEYEVENT_CHAR KEYEVENT.uChar.AsciiChar
|
||||
// #endif
|
||||
|
||||
#define KEYEVENT_PCHAR &KEYEVENT_CHAR
|
||||
|
||||
// This is for local echo (Paul Brannan 5/16/98)
|
||||
inline void DoEcho(const char *p, int l, TConsole &Console,
|
||||
TNetwork &Network, NetParams *pParams) {
|
||||
// Pause the console (Paul Brannan 8/24/98)
|
||||
if(Network.get_local_echo()) {
|
||||
ResetEvent(pParams->hUnPause);
|
||||
SetEvent(pParams->hPause);
|
||||
while (!*pParams->bNetPaused); // Pause
|
||||
|
||||
Console.WriteCtrlString(p, l);
|
||||
|
||||
SetEvent(pParams->hUnPause); // Unpause
|
||||
}
|
||||
}
|
||||
|
||||
// This is for line mode (Paul Brannan 12/31/98)
|
||||
static char buffer[1024];
|
||||
static unsigned int bufptr = 0;
|
||||
|
||||
// Line mode -- currently uses sga/echo to determine when to enter line mode
|
||||
// (as in RFC 858), but correct behaviour is as described in RFC 1184.
|
||||
// (Paul Brannan 12/31/98)
|
||||
// FIX ME!! What to do with unflushed data when we change from line mode
|
||||
// to character mode?
|
||||
inline bool DoLineModeSpecial(char keychar, TConsole &Console, TNetwork &Network,
|
||||
NetParams *pParams) {
|
||||
if(keychar == VK_BACK) {
|
||||
if(bufptr) bufptr--;
|
||||
DoEcho("\b \b", 3, Console, Network, pParams);
|
||||
return true;
|
||||
} else if(keychar == VK_RETURN) {
|
||||
Network.WriteString(buffer, bufptr);
|
||||
Network.WriteString("\012", 1);
|
||||
DoEcho("\r\n", 2, Console, Network, pParams);
|
||||
bufptr = 0;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline void DoLineMode(const char *p, int p_len, TConsole &Console,
|
||||
TNetwork &Network) {
|
||||
if(Network.get_line_mode()) {
|
||||
if(bufptr < sizeof(buffer) + p_len - 1) {
|
||||
memcpy(buffer + bufptr, p, p_len);
|
||||
bufptr += p_len;
|
||||
} else {
|
||||
Console.Beep();
|
||||
}
|
||||
} else {
|
||||
Network.WriteString(p, p_len);
|
||||
}
|
||||
}
|
||||
|
||||
// Paul Brannan 5/27/98
|
||||
// Fixed this code for use with appliation cursor keys
|
||||
// This should probably be optimized; it's pretty ugly as it is
|
||||
// Rewrite #1: now uses ClosestStateKey (Paul Brannan 12/9/98)
|
||||
const char *ClosestStateKey(WORD keyCode, DWORD keyState,
|
||||
KeyTranslator &KeyTrans) {
|
||||
char const *p;
|
||||
|
||||
if((p = KeyTrans.TranslateKey(keyCode, keyState))) return p;
|
||||
|
||||
// Check numlock and scroll lock (Paul Brannan 9/23/98)
|
||||
if((p = KeyTrans.TranslateKey(keyCode, keyState & ~NUMLOCK_ON))) return p;
|
||||
if((p = KeyTrans.TranslateKey(keyCode, keyState & ~ENHANCED_KEY
|
||||
& ~NUMLOCK_ON))) return p;
|
||||
if((p = KeyTrans.TranslateKey(keyCode, keyState & ~SCROLLLOCK_ON))) return p;
|
||||
if((p = KeyTrans.TranslateKey(keyCode, keyState & ~ENHANCED_KEY
|
||||
& ~SCROLLLOCK_ON))) return p;
|
||||
|
||||
// John Ioannou (roryt@hol.gr)
|
||||
// Athens 31/03/97 00:25am GMT+2
|
||||
// fix for win95 CAPSLOCK bug
|
||||
// first check if the user has keys with capslock and then we filter it
|
||||
if((p = KeyTrans.TranslateKey(keyCode, keyState & ~ENHANCED_KEY))) return p;
|
||||
if((p = KeyTrans.TranslateKey(keyCode, keyState & ~CAPSLOCK_ON))) return p;
|
||||
if((p = KeyTrans.TranslateKey(keyCode, keyState & ~ENHANCED_KEY
|
||||
& ~CAPSLOCK_ON))) return p;
|
||||
|
||||
return 0; // we couldn't find a suitable key translation
|
||||
}
|
||||
|
||||
const char *FindClosestKey(WORD keyCode, DWORD keyState,
|
||||
KeyTranslator &KeyTrans) {
|
||||
char const *p;
|
||||
|
||||
// Paul Brannan 7/20/98
|
||||
if(ini.get_alt_erase()) {
|
||||
if(keyCode == VK_BACK) {
|
||||
keyCode = VK_DELETE;
|
||||
keyState |= ENHANCED_KEY;
|
||||
} else if(keyCode == VK_DELETE && (keyState & ENHANCED_KEY)) {
|
||||
keyCode = VK_BACK;
|
||||
keyState &= ~ENHANCED_KEY;
|
||||
}
|
||||
}
|
||||
|
||||
DWORD ext_mode = KeyTrans.get_ext_mode();
|
||||
if(ext_mode) {
|
||||
// Not as fast as an unrolled loop, but certainly more
|
||||
// compact (Paul Brannan 12/9/98)
|
||||
for(DWORD j = ext_mode; j >= APP_KEY; j -= APP_KEY) {
|
||||
if((j | ext_mode) == ext_mode) {
|
||||
if((p = ClosestStateKey(keyCode, keyState | j,
|
||||
KeyTrans))) return p;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ClosestStateKey(keyCode, keyState, KeyTrans);
|
||||
}
|
||||
|
||||
// Paul Brannan Feb. 22, 1999
|
||||
int do_op(tn_ops op, TNetwork &Network, Tnclip &Clipboard) {
|
||||
switch(op) {
|
||||
case TN_ESCAPE:
|
||||
return TNPROMPT;
|
||||
case TN_SCROLLBACK:
|
||||
return TNSCROLLBACK;
|
||||
case TN_DIAL:
|
||||
return TNSPAWN;
|
||||
case TN_PASTE:
|
||||
if(ini.get_keyboard_paste()) Clipboard.Paste();
|
||||
else return 0;
|
||||
break;
|
||||
case TN_NULL:
|
||||
Network.WriteString("", 1);
|
||||
return 0;
|
||||
case TN_CR:
|
||||
Network.WriteString("\r", 2); // CR must be followed by NUL
|
||||
return 0;
|
||||
case TN_CRLF:
|
||||
Network.WriteString("\r\n", 2);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int telProcessConsole(NetParams *pParams, KeyTranslator &KeyTrans,
|
||||
TConsole &Console, TNetwork &Network, TMouse &Mouse,
|
||||
Tnclip &Clipboard, HANDLE hThread)
|
||||
{
|
||||
KeyDefType_const keydef;
|
||||
const char *p;
|
||||
int p_len;
|
||||
unsigned int i;
|
||||
int opval;
|
||||
HANDLE hConsole = GetStdHandle(STD_INPUT_HANDLE);
|
||||
|
||||
SetConsoleMode(hConsole, ini.get_enable_mouse() ? ENABLE_MOUSE_INPUT : 0);
|
||||
|
||||
const DWORD nHandle = 2;
|
||||
HANDLE hHandle[nHandle] = {hConsole, pParams->hExit};
|
||||
|
||||
for (;;) {
|
||||
DWORD dwInput;
|
||||
switch (WaitForMultipleObjects(nHandle, hHandle, FALSE, INFINITE)) {
|
||||
case WAIT_OBJECT_0: {
|
||||
|
||||
// Paul Brannan 7/29/98
|
||||
if(ini.get_input_redir()) {
|
||||
char InputBuffer[10];
|
||||
|
||||
// Correction from Joe Manns <joe.manns@ardenenginneers.com>
|
||||
// to fix race conditions (4/13/99)
|
||||
int bResult;
|
||||
bResult = ReadFile(hConsole, InputBuffer, 10, &dwInput, 0);
|
||||
if(bResult && dwInput == 0) return TNNOCON;
|
||||
|
||||
// no key translation for redirected input
|
||||
Network.WriteString(InputBuffer, dwInput);
|
||||
break;
|
||||
}
|
||||
|
||||
INPUT_RECORD InputRecord[11];
|
||||
if (!ReadConsoleInput(hConsole, &InputRecord[0], 10, &dwInput))
|
||||
return TNPROMPT;
|
||||
|
||||
for (i = 0; (unsigned)i < dwInput; i++){
|
||||
switch (InputRecord[i].EventType) {
|
||||
case KEY_EVENT:{
|
||||
if (KEYEVENT.bKeyDown) {
|
||||
|
||||
WORD keyCode = KEYEVENT.wVirtualKeyCode;
|
||||
DWORD keyState = KEYEVENT.dwControlKeyState;
|
||||
|
||||
// Paul Brannan 5/27/98
|
||||
// Moved the code that was here to FindClosestKey()
|
||||
keydef.szKeyDef = FindClosestKey(keyCode,
|
||||
keyState, KeyTrans);
|
||||
|
||||
if(keydef.szKeyDef) {
|
||||
if(!keydef.op->sendstr)
|
||||
if((opval = do_op(keydef.op->the_op, Network,
|
||||
Clipboard)) != 0)
|
||||
return opval;
|
||||
}
|
||||
|
||||
if(Network.get_line_mode()) {
|
||||
if(DoLineModeSpecial(KEYEVENT_CHAR, Console, Network, pParams))
|
||||
continue;
|
||||
}
|
||||
|
||||
p = keydef.szKeyDef;
|
||||
if (p == NULL) { // if we don't have a translator
|
||||
if(!KEYEVENT_CHAR) continue;
|
||||
p_len = 1;
|
||||
p = KEYEVENT_PCHAR;
|
||||
} else {
|
||||
p_len = strlen(p);
|
||||
}
|
||||
|
||||
// Local echo (Paul Brannan 5/16/98)
|
||||
DoEcho(p, p_len, Console, Network, pParams);
|
||||
// Line mode (Paul Brannan 12/31/98)
|
||||
DoLineMode(p, p_len, Console, Network);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MOUSE_EVENT:
|
||||
if(!InputRecord[i].Event.MouseEvent.dwEventFlags) {
|
||||
ResetEvent(pParams->hUnPause);
|
||||
SetEvent(pParams->hPause);
|
||||
while (!*pParams->bNetPaused); // thread paused
|
||||
// SuspendThread(hThread);
|
||||
|
||||
// Put the mouse's X and Y coords back into the
|
||||
// input buffer
|
||||
DWORD Result;
|
||||
WriteConsoleInput(hConsole, &InputRecord[i], 1,
|
||||
&Result);
|
||||
|
||||
Mouse.doMouse();
|
||||
|
||||
SetEvent(pParams->hUnPause);
|
||||
// ResumeThread(hThread);
|
||||
}
|
||||
break;
|
||||
|
||||
case FOCUS_EVENT:
|
||||
break;
|
||||
case WINDOW_BUFFER_SIZE_EVENT:
|
||||
// FIX ME!! This should take care of the window re-sizing bug
|
||||
// Unfortunately, it doesn't.
|
||||
Console.sync();
|
||||
Network.do_naws(Console.GetWidth(), Console.GetHeight());
|
||||
break;
|
||||
}
|
||||
|
||||
} // keep going until no more input
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return TNNOCON;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WORD scrollkeys() {
|
||||
HANDLE hConsole = GetStdHandle(STD_INPUT_HANDLE);
|
||||
INPUT_RECORD InputRecord;
|
||||
BOOL done = FALSE;
|
||||
|
||||
while (!done) {
|
||||
DWORD dwInput;
|
||||
WaitForSingleObject( hConsole, INFINITE );
|
||||
if (!ReadConsoleInput(hConsole, &InputRecord, 1, &dwInput)){
|
||||
done = TRUE;
|
||||
continue;
|
||||
}
|
||||
if (InputRecord.EventType == KEY_EVENT &&
|
||||
InputRecord.Event.KeyEvent.bKeyDown ) {
|
||||
// Why not just return the key code? (Paul Brannan 12/5/98)
|
||||
return InputRecord.Event.KeyEvent.wVirtualKeyCode;
|
||||
} else if(InputRecord.EventType == MOUSE_EVENT) {
|
||||
if(!InputRecord.Event.MouseEvent.dwEventFlags) {
|
||||
// Put the mouse's X and Y coords back into the input buffer
|
||||
WriteConsoleInput(hConsole, &InputRecord, 1, &dwInput);
|
||||
return SC_MOUSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return SC_ESC;
|
||||
}
|
||||
|
||||
// FIX ME!! This is more evidence that tncon.cpp ought to have class structure
|
||||
// (Paul Brannan 12/10/98)
|
||||
|
||||
// Bryan Montgomery 10/14/98
|
||||
static TNetwork net;
|
||||
void setTNetwork(TNetwork tnet) {
|
||||
net = tnet;
|
||||
}
|
||||
|
||||
// Thomas Briggs 8/17/98
|
||||
BOOL WINAPI ControlEventHandler(DWORD event) {
|
||||
switch(event) {
|
||||
case CTRL_BREAK_EVENT:
|
||||
// Bryan Montgomery 10/14/98
|
||||
if(ini.get_control_break_as_c()) net.WriteString("\x3",1);
|
||||
return TRUE;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
34
rosapps/net/telnet/src/tncon.h
Normal file
34
rosapps/net/telnet/src/tncon.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
#ifndef __TNCON_H
|
||||
#define __TNCON_H
|
||||
|
||||
#include "tparams.h"
|
||||
#include "tnclip.h"
|
||||
#include "ttelhndl.h"
|
||||
|
||||
enum {
|
||||
SC_UP,
|
||||
SC_DOWN,
|
||||
SC_ESC,
|
||||
SC_MOUSE
|
||||
};
|
||||
|
||||
enum {
|
||||
TNNOCON,
|
||||
TNPROMPT,
|
||||
TNSCROLLBACK,
|
||||
TNSPAWN,
|
||||
TNDONE
|
||||
};
|
||||
|
||||
int telProcessConsole(NetParams *pParams, KeyTranslator &KeyTrans,
|
||||
TConsole &Console, TNetwork &Network, TMouse &Mouse,
|
||||
Tnclip &Clipboard, HANDLE hThread);
|
||||
WORD scrollkeys ();
|
||||
|
||||
// Thomas Briggs 8/17/98
|
||||
BOOL WINAPI ControlEventHandler(DWORD);
|
||||
|
||||
// Bryan Montgomery 10/14/98
|
||||
void setTNetwork(TNetwork);
|
||||
|
||||
#endif
|
703
rosapps/net/telnet/src/tnconfig.cpp
Normal file
703
rosapps/net/telnet/src/tnconfig.cpp
Normal file
|
@ -0,0 +1,703 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
//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
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// tnconfig.cpp
|
||||
// Written by Paul Brannan <pbranna@clemson.edu>
|
||||
// Last modified August 30, 1998
|
||||
//
|
||||
// This is a class designed for use with Brad Johnson's Console Telnet
|
||||
// see the file tnconfig.h for more information
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <locale.h>
|
||||
#include <memory.h>
|
||||
#include <io.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include "tnconfig.h"
|
||||
|
||||
// Turn off the "forcing value to bool 'true' or 'false'" warning
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable: 4800)
|
||||
#endif
|
||||
|
||||
// This is the ini variable that is used for everybody
|
||||
TConfig ini;
|
||||
|
||||
TConfig::TConfig() {
|
||||
// set all default values
|
||||
startdir[0] = '\0';
|
||||
keyfile[0] = '\0';
|
||||
inifile[0] = '\0';
|
||||
dumpfile[0] = '\0';
|
||||
term[0] = '\0';
|
||||
default_config[0] = '\0';
|
||||
strcpy(printer_name, "LPT1");
|
||||
|
||||
input_redir = 0;
|
||||
output_redir = 0;
|
||||
strip_redir = FALSE;
|
||||
|
||||
dstrbksp = FALSE;
|
||||
eightbit_ansi = FALSE;
|
||||
vt100_mode = FALSE;
|
||||
disable_break = FALSE;
|
||||
speaker_beep = TRUE;
|
||||
do_beep = TRUE;
|
||||
preserve_colors = FALSE;
|
||||
wrapline = TRUE;
|
||||
lock_linewrap = FALSE;
|
||||
fast_write = TRUE;
|
||||
enable_mouse = TRUE;
|
||||
alt_erase = FALSE;
|
||||
wide_enable = FALSE;
|
||||
keyboard_paste = FALSE;
|
||||
set_title = TRUE;
|
||||
|
||||
blink_bg = -1;
|
||||
blink_fg = 2;
|
||||
underline_bg = -1;
|
||||
underline_fg = 3;
|
||||
ulblink_bg = -1;
|
||||
ulblink_fg = 1;
|
||||
normal_bg = -1;
|
||||
normal_fg = -1;
|
||||
scroll_bg = 0;
|
||||
scroll_fg = 7;
|
||||
status_bg = 1;
|
||||
status_fg = 15;
|
||||
|
||||
buffer_size = 2048;
|
||||
|
||||
term_width = -1;
|
||||
term_height = -1;
|
||||
window_width = -1;
|
||||
window_height = -1;
|
||||
|
||||
strcpy(escape_key, "]");
|
||||
strcpy(scrollback_key, "[");
|
||||
strcpy(dial_key, "\\");
|
||||
strcpy(default_config, "ANSI");
|
||||
strcpy(term, "ansi");
|
||||
|
||||
strcpy(scroll_mode, "DUMP");
|
||||
scroll_size=32000;
|
||||
scroll_enable=TRUE;
|
||||
|
||||
host[0] = '\0';
|
||||
port = "23";
|
||||
|
||||
init_varlist();
|
||||
|
||||
aliases = NULL;
|
||||
}
|
||||
|
||||
TConfig::~TConfig() {
|
||||
if(aliases) {
|
||||
for(int j = 0; j < alias_total; j++) delete[] aliases[j];
|
||||
delete[] aliases;
|
||||
}
|
||||
}
|
||||
|
||||
enum ini_data_type {
|
||||
INI_STRING,
|
||||
INI_INT,
|
||||
INI_BOOL
|
||||
};
|
||||
|
||||
enum {
|
||||
INIFILE,
|
||||
KEYFILE,
|
||||
DUMPFILE,
|
||||
DEFAULT_CONFIG,
|
||||
TERM,
|
||||
INPUT_REDIR,
|
||||
OUTPUT_REDIR,
|
||||
STRIP_REDIR,
|
||||
DSTRBKSP,
|
||||
EIGHTBIT_ANSI,
|
||||
VT100_MODE,
|
||||
DISABLE_BREAK,
|
||||
SPEAKER_BEEP,
|
||||
DO_BEEP,
|
||||
PRESERVE_COLORS,
|
||||
WRAP_LINE,
|
||||
LOCK_LINEWRAP,
|
||||
FAST_WRITE,
|
||||
TERM_WIDTH,
|
||||
TERM_HEIGHT,
|
||||
WINDOW_WIDTH,
|
||||
WINDOW_HEIGHT,
|
||||
WIDE_ENABLE,
|
||||
CTRLBREAK_AS_CTRLC,
|
||||
BUFFER_SIZE,
|
||||
SET_TITLE,
|
||||
BLINK_BG,
|
||||
BLINK_FG,
|
||||
UNDERLINE_BG,
|
||||
UNDERLINE_FG,
|
||||
ULBLINK_BG,
|
||||
ULBLINK_FG,
|
||||
NORMAL_BG,
|
||||
NORMAL_FG,
|
||||
SCROLL_BG,
|
||||
SCROLL_FG,
|
||||
STATUS_BG,
|
||||
STATUS_FG,
|
||||
PRINTER_NAME,
|
||||
ENABLE_MOUSE,
|
||||
ESCAPE_KEY,
|
||||
SCROLLBACK_KEY,
|
||||
DIAL_KEY,
|
||||
ALT_ERASE,
|
||||
KEYBOARD_PASTE,
|
||||
SCROLL_MODE,
|
||||
SCROLL_SIZE,
|
||||
SCROLL_ENABLE,
|
||||
SCRIPTNAME,
|
||||
SCRIPT_ENABLE,
|
||||
NETPIPE,
|
||||
IOPIPE,
|
||||
|
||||
MAX_INI_VARS // must be last
|
||||
};
|
||||
|
||||
struct ini_variable {
|
||||
char *name; // variable name
|
||||
char *section; // name of ini file section the variable is in
|
||||
enum ini_data_type data_type; // type of data
|
||||
void *ini_data; // pointer to data
|
||||
int max_size; // max size if string
|
||||
};
|
||||
|
||||
// Note: default values are set in the constructor, TConfig()
|
||||
ini_variable ini_varlist[MAX_INI_VARS];
|
||||
|
||||
enum {
|
||||
KEYBOARD,
|
||||
TERMINAL,
|
||||
COLORS,
|
||||
MOUSE,
|
||||
PRINTER,
|
||||
SCROLLBACK,
|
||||
SCRIPTING,
|
||||
PIPES,
|
||||
|
||||
MAX_INI_GROUPS // Must be last
|
||||
};
|
||||
|
||||
char *ini_groups[MAX_INI_GROUPS];
|
||||
|
||||
void TConfig::init_varlist() {
|
||||
static const ini_variable static_ini_varlist[MAX_INI_VARS] = {
|
||||
{"Inifile", NULL, INI_STRING, &inifile, sizeof(inifile)},
|
||||
{"Keyfile", "Keyboard", INI_STRING, &keyfile, sizeof(keyfile)},
|
||||
{"Dumpfile", "Terminal", INI_STRING, &dumpfile, sizeof(dumpfile)},
|
||||
{"Default_Config","Keyboard", INI_STRING, &default_config, sizeof(default_config)},
|
||||
{"Term", "Terminal", INI_STRING, &term, sizeof(term)},
|
||||
{"Input_Redir", "Terminal", INI_INT, &input_redir, 0},
|
||||
{"Output_Redir","Terminal", INI_INT, &output_redir, 0},
|
||||
{"Strip_Redir", "Terminal", INI_BOOL, &strip_redir, 0},
|
||||
{"Destructive_Backspace","Terminal",INI_BOOL, &dstrbksp, 0},
|
||||
{"EightBit_Ansi","Terminal", INI_BOOL, &eightbit_ansi, 0},
|
||||
{"VT100_Mode", "Terminal", INI_BOOL, &vt100_mode, 0},
|
||||
{"Disable_Break","Terminal", INI_BOOL, &disable_break, 0},
|
||||
{"Speaker_Beep","Terminal", INI_BOOL, &speaker_beep, 0},
|
||||
{"Beep", "Terminal", INI_BOOL, &do_beep, 0},
|
||||
{"Preserve_Colors","Terminal", INI_BOOL, &preserve_colors, 0},
|
||||
{"Wrap_Line", "Terminal", INI_BOOL, &wrapline, 0},
|
||||
{"Lock_linewrap","Terminal", INI_BOOL, &lock_linewrap, 0},
|
||||
{"Fast_Write", "Terminal", INI_BOOL, &fast_write, 0},
|
||||
{"Term_Width", "Terminal", INI_INT, &term_width, 0},
|
||||
{"Term_Height", "Terminal", INI_INT, &term_height, 0},
|
||||
{"Window_Width","Terminal", INI_INT, &window_width, 0},
|
||||
{"Window_Height","Terminal", INI_INT, &window_height, 0},
|
||||
{"Wide_Enable", "Terminal", INI_BOOL, &wide_enable, 0},
|
||||
{"Ctrlbreak_as_Ctrlc","Keyboard", INI_BOOL, &ctrlbreak_as_ctrlc, 0},
|
||||
{"Buffer_Size", "Terminal", INI_INT, &buffer_size, 0},
|
||||
{"Set_Title", "Terminal", INI_BOOL, &set_title, 0},
|
||||
{"Blink_bg", "Colors", INI_INT, &blink_bg, 0},
|
||||
{"Blink_fg", "Colors", INI_INT, &blink_fg, 0},
|
||||
{"Underline_bg","Colors", INI_INT, &underline_bg, 0},
|
||||
{"Underline_fg","Colors", INI_INT, &underline_fg, 0},
|
||||
{"UlBlink_bg", "Colors", INI_INT, &ulblink_bg, 0},
|
||||
{"UlBlink_fg", "Colors", INI_INT, &ulblink_fg, 0},
|
||||
{"Normal_bg", "Colors", INI_INT, &normal_bg, 0},
|
||||
{"Normal_fg", "Colors", INI_INT, &normal_fg, 0},
|
||||
{"Scroll_bg", "Colors", INI_INT, &scroll_bg, 0},
|
||||
{"Scroll_fg", "Colors", INI_INT, &scroll_fg, 0},
|
||||
{"Status_bg", "Colors", INI_INT, &status_bg, 0},
|
||||
{"Status_fg", "Colors", INI_INT, &status_fg, 0},
|
||||
{"Enable_Mouse","Mouse", INI_BOOL, &enable_mouse, 0},
|
||||
{"Printer_Name","Printer", INI_STRING, &printer_name, sizeof(printer_name)},
|
||||
{"Escape_Key", "Keyboard", INI_STRING, &escape_key, 1},
|
||||
{"Scrollback_Key","Keyboard", INI_STRING, &scrollback_key, 1},
|
||||
{"Dial_Key", "Keyboard", INI_STRING, &dial_key, 1},
|
||||
{"Alt_Erase", "Keyboard", INI_BOOL, &alt_erase, 0},
|
||||
{"Keyboard_Paste","Keyboard", INI_BOOL, &keyboard_paste, 0},
|
||||
{"Scroll_Mode", "Scrollback", INI_STRING, &scroll_mode, sizeof(scroll_mode)},
|
||||
{"Scroll_Size", "Scrollback", INI_INT, &scroll_size, 0},
|
||||
{"Scroll_Enable","Scrollback", INI_BOOL, &scroll_enable, 0},
|
||||
{"Scriptname", "Scripting", INI_STRING, &scriptname, sizeof(scriptname)},
|
||||
{"Script_enable","Scripting", INI_BOOL, &script_enable, 0},
|
||||
{"Netpipe", "Pipes", INI_STRING, &netpipe, sizeof(netpipe)},
|
||||
{"Iopipe", "Pipes", INI_STRING, &iopipe, sizeof(iopipe)}
|
||||
};
|
||||
|
||||
static const char *static_ini_groups[MAX_INI_GROUPS] = {
|
||||
"Keyboard",
|
||||
"Terminal",
|
||||
"Colors",
|
||||
"Mouse",
|
||||
"Printer",
|
||||
"Scrollback",
|
||||
"Scripting",
|
||||
"Pipes"
|
||||
};
|
||||
|
||||
memcpy(ini_varlist, static_ini_varlist, sizeof(ini_varlist));
|
||||
memcpy(ini_groups, static_ini_groups, sizeof(ini_groups));
|
||||
}
|
||||
|
||||
void TConfig::init(char *dirname, char *execname) {
|
||||
// Copy temporary dirname to permanent startdir
|
||||
strncpy(startdir, dirname, sizeof(startdir));
|
||||
startdir[sizeof(startdir) - 1] = 0;
|
||||
|
||||
// Copy temp execname to permanent exename (Thomas Briggs 12/7/98)
|
||||
strncpy(exename, execname, sizeof(exename));
|
||||
exename[sizeof(exename) - 1] = 0;
|
||||
|
||||
// Initialize INI file
|
||||
inifile_init();
|
||||
|
||||
// Initialize redir
|
||||
// Note that this must be done early, so error messages will be printed
|
||||
// properly
|
||||
redir_init();
|
||||
|
||||
// Initialize aliases (Paul Brannan 1/1/99)
|
||||
init_aliases();
|
||||
|
||||
// Make sure the file that we're trying to work with exists
|
||||
int iResult = access(inifile, 04);
|
||||
|
||||
// Thomas Briggs 9/14/98
|
||||
if( iResult == 0 )
|
||||
// Tell the user what file we are reading
|
||||
// We cannot print any messages before initializing telnet_redir
|
||||
printm(0, FALSE, MSG_CONFIG, inifile);
|
||||
else
|
||||
// Tell the user that the file doesn't exist, but later read the
|
||||
// file anyway simply to populate the defaults
|
||||
printm(0, FALSE, MSG_NOINI, inifile);
|
||||
|
||||
init_vars(); // Initialize misc. vars
|
||||
keyfile_init(); // Initialize keyfile
|
||||
}
|
||||
|
||||
// Alias support (Paul Brannan 1/1/99)
|
||||
void TConfig::init_aliases() {
|
||||
char *buffer;
|
||||
alias_total = 0;
|
||||
|
||||
// Find the correct buffer size
|
||||
// FIX ME!! some implementations of Mingw32 don't have a
|
||||
// GetPrivateProfileSecionNames function. What do we do about this?
|
||||
#ifndef __MINGW32__
|
||||
{
|
||||
int size=1024, Result = 0;
|
||||
for(;;) {
|
||||
buffer = new char[size];
|
||||
Result = GetPrivateProfileSectionNames(buffer, size, inifile);
|
||||
if(Result < size - 2) break;
|
||||
size *= 2;
|
||||
delete[] buffer;
|
||||
}
|
||||
}
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
|
||||
// Find the maximum number of aliases
|
||||
int max = 0;
|
||||
char *tmp;
|
||||
for(tmp = buffer; *tmp != 0; tmp += strlen(tmp) + 1)
|
||||
max++;
|
||||
|
||||
aliases = new char*[max];
|
||||
|
||||
// Load the aliases into an array
|
||||
for(tmp = buffer; *tmp != 0; tmp += strlen(tmp) + 1) {
|
||||
int flag = 0;
|
||||
for(int j = 0; j < MAX_INI_GROUPS; j++) {
|
||||
if(!stricmp(ini_groups[j], tmp)) flag = 1;
|
||||
}
|
||||
if(!flag) {
|
||||
aliases[alias_total] = new char[strlen(tmp)+1];
|
||||
strcpy(aliases[alias_total], tmp);
|
||||
alias_total++;
|
||||
}
|
||||
}
|
||||
|
||||
delete[] buffer;
|
||||
}
|
||||
|
||||
void TConfig::print_aliases() {
|
||||
for(int j = 0; j < alias_total; j++) {
|
||||
char alias_name[20];
|
||||
set_string(alias_name, aliases[j], sizeof(alias_name));
|
||||
for(unsigned int i = strlen(alias_name); i < sizeof(alias_name) - 1; i++)
|
||||
alias_name[i] = ' ';
|
||||
alias_name[sizeof(alias_name) - 1] = 0;
|
||||
printit(alias_name);
|
||||
if((j % 4) == 3) printit("\n");
|
||||
}
|
||||
printit("\n");
|
||||
}
|
||||
|
||||
bool find_alias(const char *alias_name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void TConfig::print_vars() {
|
||||
int j;
|
||||
for(j = 0; j < MAX_INI_VARS; j++) {
|
||||
if(print_value(ini_varlist[j].name) > 40) printit("\n");
|
||||
else if(j % 2) printit("\n");
|
||||
else printit("\t");
|
||||
}
|
||||
if(j % 2) printit("\n");
|
||||
}
|
||||
|
||||
// Paul Brannan 9/3/98
|
||||
void TConfig::print_vars(char *s) {
|
||||
if(!strnicmp(s, "all", 3)) { // Print out all vars
|
||||
print_vars();
|
||||
return;
|
||||
}
|
||||
|
||||
// See if the group exists
|
||||
int j, flag;
|
||||
for(j = 0, flag = 0; j < MAX_INI_GROUPS; j++)
|
||||
if(!stricmp(ini_groups[j], s)) break;
|
||||
// If not, print out the value of the variable by that name
|
||||
if(j == MAX_INI_GROUPS) {
|
||||
print_value(s);
|
||||
printit("\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// Print out the vars in the given group
|
||||
int count = 0;
|
||||
for(j = 0; j < MAX_INI_VARS; j++) {
|
||||
if(ini_varlist[j].section == NULL) continue;
|
||||
if(!stricmp(ini_varlist[j].section, s)) {
|
||||
if(print_value(ini_varlist[j].name) > 40) printit("\n");
|
||||
else if(count % 2) printit("\n");
|
||||
else printit("\t");
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if(count % 2) printit("\n");
|
||||
}
|
||||
|
||||
// Paul Brannan 9/3/98
|
||||
void TConfig::print_groups() {
|
||||
for(int j = 0; j < MAX_INI_GROUPS; j++) {
|
||||
char group_name[20];
|
||||
set_string(group_name, ini_groups[j], sizeof(group_name));
|
||||
for(unsigned int i = strlen(group_name); i < sizeof(group_name) - 1; i++)
|
||||
group_name[i] = ' ';
|
||||
group_name[sizeof(group_name) - 1] = 0;
|
||||
printit(group_name);
|
||||
if((j % 4) == 3) printit("\n");
|
||||
}
|
||||
printit("\n");
|
||||
}
|
||||
|
||||
// Ioannou : The index in the while causes segfaults if there is no match
|
||||
// changes to for(), and strcmp to stricmp (prompt gives rong names)
|
||||
|
||||
bool TConfig::set_value(const char *var, const char *value) {
|
||||
//int j = 0;
|
||||
//while(strcmp(var, ini_varlist[j].name) && j < MAX_INI_VARS) j++;
|
||||
for (int j = 0; j < MAX_INI_VARS; j++)
|
||||
{
|
||||
if (stricmp(var, ini_varlist[j].name) == 0)
|
||||
{
|
||||
switch(ini_varlist[j].data_type) {
|
||||
case INI_STRING:
|
||||
set_string((char *)ini_varlist[j].ini_data, value,
|
||||
ini_varlist[j].max_size);
|
||||
break;
|
||||
case INI_INT:
|
||||
*(int *)ini_varlist[j].ini_data = atoi(value);
|
||||
break;
|
||||
case INI_BOOL:
|
||||
set_bool((bool *)ini_varlist[j].ini_data, value);
|
||||
break;
|
||||
}
|
||||
// j = MAX_INI_VARS;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int TConfig::print_value(const char *var) {
|
||||
//int j = 0;
|
||||
//while(strcmp(var, ini_varlist[j].name) && j < MAX_INI_VARS) j++;
|
||||
int Result = 0;
|
||||
for (int j = 0; j < MAX_INI_VARS; j++)
|
||||
{
|
||||
if (stricmp(var, ini_varlist[j].name) == 0)
|
||||
{
|
||||
char var_name[25];
|
||||
set_string(var_name, var, sizeof(var_name));
|
||||
for(unsigned int i = strlen(var_name); i < sizeof(var_name) - 1; i++)
|
||||
var_name[i] = ' ';
|
||||
var_name[sizeof(var_name) - 1] = 0;
|
||||
Result = sizeof(var_name);
|
||||
|
||||
printit(var_name);
|
||||
printit("\t");
|
||||
Result = Result / 8 + 8;
|
||||
|
||||
switch(ini_varlist[j].data_type) {
|
||||
case INI_STRING:
|
||||
printit((char *)ini_varlist[j].ini_data);
|
||||
Result += strlen((char *)ini_varlist[j].ini_data);
|
||||
break;
|
||||
case INI_INT:
|
||||
char buffer[20]; // this may not be safe
|
||||
// Ioannou : Paul this was _itoa, but Borland needs itoa !!
|
||||
itoa(*(int *)ini_varlist[j].ini_data, buffer, 10);
|
||||
printit(buffer);
|
||||
Result += strlen(buffer);
|
||||
break;
|
||||
case INI_BOOL:
|
||||
if(*(bool *)ini_varlist[j].ini_data == true) {
|
||||
printit("on");
|
||||
Result += 2;
|
||||
} else {
|
||||
printit("off");
|
||||
Result += 3;
|
||||
}
|
||||
}
|
||||
// printit("\n");
|
||||
j = MAX_INI_VARS;
|
||||
}
|
||||
}
|
||||
return Result;
|
||||
}
|
||||
|
||||
void TConfig::init_vars() {
|
||||
char buffer[4096];
|
||||
for(int j = 0; j < MAX_INI_VARS; j++) {
|
||||
if(ini_varlist[j].section != NULL) {
|
||||
GetPrivateProfileString(ini_varlist[j].section, ini_varlist[j].name, "",
|
||||
buffer, sizeof(buffer), inifile);
|
||||
if(*buffer != 0) set_value(ini_varlist[j].name, buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TConfig::inifile_init() {
|
||||
// B. K. Oxley 9/16/98
|
||||
char* env_telnet_ini = getenv (ENV_TELNET_INI);
|
||||
if (env_telnet_ini && *env_telnet_ini) {
|
||||
strncpy (inifile, env_telnet_ini, sizeof(inifile));
|
||||
return;
|
||||
}
|
||||
|
||||
strcpy(inifile, startdir);
|
||||
if (sizeof(inifile) >= strlen(inifile)+strlen("telnet.ini")) {
|
||||
strcat(inifile,"telnet.ini"); // add the default filename to the path
|
||||
} else {
|
||||
// if there is not enough room set the path to nothing
|
||||
strcpy(inifile,"");
|
||||
}
|
||||
}
|
||||
|
||||
void TConfig::keyfile_init() {
|
||||
// check to see if there is a key config file environment variable.
|
||||
char *k;
|
||||
if ((k = getenv(ENV_TELNET_CFG)) == NULL){
|
||||
// if there is no environment variable
|
||||
GetPrivateProfileString("Keyboard", "Keyfile", "", keyfile,
|
||||
sizeof(keyfile), inifile);
|
||||
if(keyfile == 0 || *keyfile == 0) {
|
||||
// and there is no profile string
|
||||
strcpy(keyfile, startdir);
|
||||
if (sizeof(keyfile) >= strlen(keyfile)+strlen("telnet.cfg")) {
|
||||
struct stat buf;
|
||||
|
||||
strcat(keyfile,"telnet.cfg"); // add the default filename to the path
|
||||
if(stat(keyfile, &buf) != 0) {
|
||||
char *s = keyfile + strlen(keyfile) - strlen("telnet.cfg");
|
||||
strcpy(s, "keys.cfg");
|
||||
}
|
||||
} else {
|
||||
// if there is not enough room set the path to nothing
|
||||
strcpy(keyfile,"");
|
||||
}
|
||||
|
||||
// Vassili Bourdo (vassili_bourdo@softhome.net)
|
||||
} else {
|
||||
// check that keyfile really exists
|
||||
if( access(keyfile,04) == -1 ) {
|
||||
//it does not...
|
||||
char pathbuf[MAX_PATH], *fn;
|
||||
//substitute keyfile path with startdir path
|
||||
if((fn = strrchr(keyfile,'\\'))) strcpy(keyfile,fn);
|
||||
strcat(strcpy(pathbuf,startdir),keyfile);
|
||||
//check that startdir\keyfile does exist
|
||||
if( access(pathbuf,04) == -1 ) {
|
||||
//it does not...
|
||||
//so, look for it in all paths
|
||||
_searchenv(keyfile, "PATH", pathbuf);
|
||||
if( *pathbuf == 0 ) //no luck - revert it to INI file value
|
||||
GetPrivateProfileString("Keyboard", "Keyfile", "",
|
||||
keyfile, sizeof(keyfile), inifile);
|
||||
} else {
|
||||
strcpy(keyfile, pathbuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
////
|
||||
|
||||
} else {
|
||||
// set the keyfile to the value of the environment variable
|
||||
strncpy(keyfile, k, sizeof(keyfile));
|
||||
}
|
||||
}
|
||||
|
||||
void TConfig::redir_init() {
|
||||
// check to see if the environment variable 'TELNET_REDIR' is not 0;
|
||||
char* p = getenv(ENV_TELNET_REDIR);
|
||||
if (p) {
|
||||
input_redir = output_redir = atoi(p);
|
||||
if((p = getenv(ENV_INPUT_REDIR))) input_redir = atoi(p);
|
||||
if((p = getenv(ENV_OUTPUT_REDIR))) output_redir = atoi(p);
|
||||
} else {
|
||||
input_redir = output_redir = GetPrivateProfileInt("Terminal",
|
||||
"Telnet_Redir", 0, inifile);
|
||||
input_redir = GetPrivateProfileInt("Terminal",
|
||||
"Input_Redir", input_redir, inifile);
|
||||
output_redir = GetPrivateProfileInt("Terminal",
|
||||
"Output_Redir", output_redir, inifile);
|
||||
}
|
||||
if ((input_redir > 1) || (output_redir > 1))
|
||||
setlocale(LC_CTYPE,"");
|
||||
// tell isprint() to not ignore local characters, if the environment
|
||||
// variable "LANG" has a valid value (e.g. LANG=de for german characters)
|
||||
// and the file LOCALE.BLL is installed somewhere along the PATH.
|
||||
}
|
||||
|
||||
// Modified not to use getopt() by Paul Brannan 12/17/98
|
||||
bool TConfig::Process_Params(int argc, char *argv[]) {
|
||||
int optind = 1;
|
||||
char *optarg = argv[optind];
|
||||
char c;
|
||||
|
||||
while(optind < argc) {
|
||||
if(argv[optind][0] != '-') break;
|
||||
|
||||
// getopt
|
||||
c = argv[optind][1];
|
||||
if(argv[optind][2] == 0)
|
||||
optarg = argv[++optind];
|
||||
else
|
||||
optarg = &argv[optind][2];
|
||||
optind++;
|
||||
|
||||
switch(c) {
|
||||
case 'd':
|
||||
set_string(dumpfile, optarg, sizeof(dumpfile));
|
||||
printm(0, FALSE, MSG_DUMPFILE, dumpfile);
|
||||
break;
|
||||
// added support for setting options on the command-line
|
||||
// (Paul Brannan 7/31/98)
|
||||
case '-':
|
||||
{
|
||||
int j;
|
||||
for(j = 0; optarg[j] != ' ' && optarg[j] != '=' && optarg[j] != 0; j++);
|
||||
if(optarg == 0) {
|
||||
printm(0, FALSE, MSG_USAGE); // print a usage message
|
||||
printm(0, FALSE, MSG_USAGE_1);
|
||||
return FALSE;
|
||||
}
|
||||
optarg[j] = 0;
|
||||
if(!set_value(optarg, &optarg[j+1]))
|
||||
printm(0, FALSE, MSG_BADVAL, optarg);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
printm(0, FALSE, MSG_USAGE); // print a usage message
|
||||
printm(0, FALSE, MSG_USAGE_1);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
if(optind < argc)
|
||||
set_string(host, argv[optind++], sizeof(host)-1);
|
||||
if(!strnicmp(host, "telnet://", 9)) {
|
||||
// we have a URL to parse
|
||||
char *s, *t;
|
||||
|
||||
for(s = host+9, t = host; *s != 0; *(t++) = *(s++));
|
||||
*t = 0;
|
||||
for(s = host; *s != ':' && *s != 0; s++);
|
||||
if(*s != 0) {
|
||||
*(s++) = 0;
|
||||
port = s;
|
||||
}
|
||||
}
|
||||
if(optind < argc)
|
||||
port = argv[optind++];
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void TConfig::set_string(char *dest, const char *src, const int length) {
|
||||
int l = length;
|
||||
strncpy(dest, src, l);
|
||||
// dest[length-1] = '\0';
|
||||
// Ioannou : this messes strings - is this really needed ?
|
||||
// The target string, dest, might not be null-terminated
|
||||
// if the length of src is length or more.
|
||||
// it should be dest[length] = '\0' for strings with length 1
|
||||
// (Escape_string etc), but doesn't work with others (like host).
|
||||
// dest is long enough to avoid this in all the tested cases
|
||||
}
|
||||
|
||||
// Ioannou : ignore case for true or on
|
||||
|
||||
void TConfig::set_bool(bool *boolval, const char *str) {
|
||||
if(!stricmp(str, "true")) *boolval = true;
|
||||
else if(!stricmp(str, "on")) *boolval = true;
|
||||
else *boolval = (bool)atoi(str);
|
||||
}
|
211
rosapps/net/telnet/src/tnconfig.h
Normal file
211
rosapps/net/telnet/src/tnconfig.h
Normal file
|
@ -0,0 +1,211 @@
|
|||
// Tnconfig.h
|
||||
// Written by Paul Brannan <pbranna@clemson.edu>
|
||||
//
|
||||
// This is a class designed for use with Brad Johnson's Console Telnet
|
||||
// It reads an ini file and keeps the settings for later retrieval.
|
||||
// It does not store any information about the current settings, only default
|
||||
// or recommended settings.
|
||||
|
||||
#ifndef __TNCONFIG_H
|
||||
#define __TNCONFIG_H
|
||||
|
||||
// Ioannou 2 June 98: Borland needs them - quick hack
|
||||
#ifdef __BORLANDC__
|
||||
#define bool BOOL
|
||||
#define true TRUE
|
||||
#define false FALSE
|
||||
#endif // __BORLANDC__
|
||||
|
||||
#include "tnerror.h"
|
||||
|
||||
#define ENV_TELNET_CFG "TELNET_CFG"
|
||||
#define ENV_TELNET_REDIR "TELNET_REDIR"
|
||||
#define ENV_INPUT_REDIR "TELNET_INPUT_REDIR"
|
||||
#define ENV_OUTPUT_REDIR "TENLET_OUTPUT_REDIR"
|
||||
#define ENV_TELNET_INI "TELNET_INI"
|
||||
|
||||
class TConfig {
|
||||
public:
|
||||
TConfig();
|
||||
~TConfig();
|
||||
|
||||
// Miscellaneous strings
|
||||
const char *get_startdir() const {return startdir;}
|
||||
const char *get_exename() const {return exename;}
|
||||
const char *get_keyfile() const {return keyfile;}
|
||||
const char *get_inifile() const {return inifile;}
|
||||
const char *get_dumpfile() const {return dumpfile;}
|
||||
const char *get_term() const {return term;}
|
||||
const char *get_printer_name() const {return printer_name;}
|
||||
const char *get_default_config() const {return default_config;}
|
||||
|
||||
// Terminal settings
|
||||
int get_input_redir() const {return input_redir;}
|
||||
int get_output_redir() const {return output_redir;}
|
||||
bool get_strip_redir() const {return strip_redir;}
|
||||
bool get_dstrbksp() const {return dstrbksp;}
|
||||
bool get_eightbit_ansi() const {return eightbit_ansi;}
|
||||
bool get_vt100_mode() const {return vt100_mode;}
|
||||
bool get_disable_break() const {return disable_break;}
|
||||
bool get_speaker_beep() const {return speaker_beep;}
|
||||
bool get_do_beep() const {return do_beep;}
|
||||
bool get_preserve_colors() const {return preserve_colors;}
|
||||
bool get_wrapline() const {return wrapline;}
|
||||
bool get_fast_write() const {return fast_write;}
|
||||
bool get_lock_linewrap() const {return lock_linewrap;}
|
||||
bool get_set_title() const { return set_title;}
|
||||
int get_term_width() const {return term_width;}
|
||||
int get_term_height() const {return term_height;}
|
||||
int get_window_width() const {return window_width;}
|
||||
int get_window_height() const {return window_height;}
|
||||
bool get_wide_enable() const {return wide_enable;}
|
||||
bool get_control_break_as_c() const {return ctrlbreak_as_ctrlc;}
|
||||
int get_buffer_size() const {return buffer_size;}
|
||||
|
||||
// Colors
|
||||
int get_blink_bg() const {return blink_bg;}
|
||||
int get_blink_fg() const {return blink_fg;}
|
||||
int get_underline_bg() const {return underline_bg;}
|
||||
int get_underline_fg() const {return underline_fg;}
|
||||
int get_ulblink_bg() const {return ulblink_bg;}
|
||||
int get_ulblink_fg() const {return ulblink_fg;}
|
||||
int get_normal_bg() const {return normal_bg;}
|
||||
int get_normal_fg() const {return normal_fg;}
|
||||
int get_scroll_bg() const {return scroll_bg;}
|
||||
int get_scroll_fg() const {return scroll_fg;}
|
||||
int get_status_bg() const {return status_bg;}
|
||||
int get_status_fg() const {return status_fg;}
|
||||
|
||||
// Mouse
|
||||
bool get_enable_mouse() const {return enable_mouse;}
|
||||
|
||||
// Keyboard
|
||||
char get_escape_key() const {return escape_key[0];}
|
||||
char get_scrollback_key() const {return scrollback_key[0];}
|
||||
char get_dial_key() const {return dial_key[0];}
|
||||
bool get_alt_erase() const {return alt_erase;}
|
||||
bool get_keyboard_paste() const {return keyboard_paste;}
|
||||
|
||||
// Scrollback
|
||||
const char *get_scroll_mode() const {return scroll_mode;}
|
||||
bool get_scroll_enable() const {return scroll_enable;}
|
||||
int get_scroll_size() const {return scroll_size;}
|
||||
|
||||
// Scripting
|
||||
const char *get_scriptname() const {return scriptname;}
|
||||
bool get_script_enable() const {return script_enable;}
|
||||
|
||||
// Pipes
|
||||
const char *get_netpipe() const {return netpipe;}
|
||||
const char *get_iopipe() const {return iopipe;}
|
||||
|
||||
// Host configuration
|
||||
const char *get_host() const {return host;}
|
||||
const char *get_port() const {return port;}
|
||||
|
||||
// Initialization
|
||||
void init(char *dirname, char *exename);
|
||||
bool Process_Params(int argc, char *argv[]);
|
||||
|
||||
// Ini variables
|
||||
void print_vars();
|
||||
void print_vars(char *s);
|
||||
void print_groups();
|
||||
bool set_value(const char *var, const char *value);
|
||||
int print_value(const char *var);
|
||||
|
||||
// Aliases
|
||||
void print_aliases();
|
||||
bool find_alias(const char *alias_name);
|
||||
|
||||
private:
|
||||
|
||||
void inifile_init();
|
||||
void keyfile_init();
|
||||
void redir_init();
|
||||
void init_varlist();
|
||||
void init_vars();
|
||||
void init_aliases();
|
||||
void set_string(char *dest, const char *src, const int length);
|
||||
void set_bool(bool *boolval, const char *str);
|
||||
|
||||
// Miscellaneous strings
|
||||
char startdir[MAX_PATH];
|
||||
char exename[MAX_PATH];
|
||||
char keyfile[MAX_PATH*2];
|
||||
char inifile[MAX_PATH*2];
|
||||
char dumpfile[MAX_PATH*2];
|
||||
char printer_name[MAX_PATH*2];
|
||||
char term[128];
|
||||
char default_config[128];
|
||||
|
||||
// Terminal
|
||||
int input_redir, output_redir;
|
||||
bool strip_redir;
|
||||
bool dstrbksp;
|
||||
bool eightbit_ansi;
|
||||
bool vt100_mode;
|
||||
bool disable_break;
|
||||
bool speaker_beep;
|
||||
bool do_beep;
|
||||
bool preserve_colors;
|
||||
bool wrapline;
|
||||
bool lock_linewrap;
|
||||
bool fast_write;
|
||||
bool set_title;
|
||||
int term_width, term_height;
|
||||
int window_width, window_height;
|
||||
bool wide_enable;
|
||||
bool ctrlbreak_as_ctrlc;
|
||||
int buffer_size;
|
||||
|
||||
// Colors
|
||||
int blink_bg;
|
||||
int blink_fg;
|
||||
int underline_bg;
|
||||
int underline_fg;
|
||||
int ulblink_bg;
|
||||
int ulblink_fg;
|
||||
int normal_bg;
|
||||
int normal_fg;
|
||||
int scroll_bg;
|
||||
int scroll_fg;
|
||||
int status_bg;
|
||||
int status_fg;
|
||||
|
||||
// Mouse
|
||||
bool enable_mouse;
|
||||
|
||||
// Keyboard
|
||||
char escape_key[2];
|
||||
char scrollback_key[2];
|
||||
char dial_key[2];
|
||||
bool alt_erase;
|
||||
bool keyboard_paste;
|
||||
|
||||
// Scrollback
|
||||
char scroll_mode[8];
|
||||
bool scroll_enable;
|
||||
int scroll_size;
|
||||
|
||||
// Scripting
|
||||
char scriptname[MAX_PATH*2];
|
||||
bool script_enable;
|
||||
|
||||
// Pipes
|
||||
char netpipe[MAX_PATH*2];
|
||||
char iopipe[MAX_PATH*2];
|
||||
|
||||
// Host configration
|
||||
char host[128];
|
||||
char *port;
|
||||
|
||||
// Aliases
|
||||
char **aliases;
|
||||
int alias_total;
|
||||
|
||||
};
|
||||
|
||||
extern TConfig ini;
|
||||
|
||||
#endif
|
220
rosapps/net/telnet/src/tnerror.cpp
Normal file
220
rosapps/net/telnet/src/tnerror.cpp
Normal file
|
@ -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
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Module: tnerror.cpp
|
||||
//
|
||||
// Contents: error reporting
|
||||
//
|
||||
// Product: telnet
|
||||
//
|
||||
// Revisions: June 15, 1998 Paul Brannan <pbranna@clemson.edu>
|
||||
// May 15, 1998 Paul Brannan
|
||||
// 5.April.1997 jbj@nounname.com
|
||||
// 5.Dec.1996 jbj@nounname.com
|
||||
// Version 2.0
|
||||
//
|
||||
// 02.Apr.1995 igor.milavec@uni-lj.si
|
||||
// Original code
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "tnerror.h"
|
||||
#include "ttelhndl.h" // Paul Brannan 5/25/98
|
||||
#include "tnconfig.h" // Paul Brannan 5/25/98
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifndef LANG_USER_DEFAULT
|
||||
#define LANG_USER_DEFAULT 400
|
||||
#endif
|
||||
|
||||
// This has been moved to tnconfig.cpp
|
||||
// int Telnet_Redir = 0;
|
||||
// Telnet_Redir is set to the value of the environment variable TELNET_REDIR
|
||||
// in main.
|
||||
|
||||
int printit(const char * it){
|
||||
DWORD numwritten;
|
||||
if (!ini.get_output_redir()) {
|
||||
if (!WriteConsole(
|
||||
GetStdHandle(STD_OUTPUT_HANDLE), // handle of a console screen buffer
|
||||
it, // address of buffer to write from
|
||||
strlen(it), // number of characters to write
|
||||
&numwritten, // address of number of characters written
|
||||
0 // reserved
|
||||
)) return -1;
|
||||
// FIX ME!!! We need to tell the console that the cursor has moved.
|
||||
// Does this mean making Console global?
|
||||
// Paul Brannan 6/14/98
|
||||
// Console.sync();
|
||||
}else{
|
||||
if (!WriteFile(
|
||||
GetStdHandle(STD_OUTPUT_HANDLE), // handle of a console screen buffer
|
||||
it, // address of buffer to write from
|
||||
strlen(it), // number of characters to write
|
||||
&numwritten, // address of number of characters written
|
||||
NULL // no overlapped I/O
|
||||
)) return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int printm(LPTSTR szModule, BOOL fSystem, DWORD dwMessageId, ...)
|
||||
{
|
||||
int Result = 0;
|
||||
|
||||
HMODULE hModule = 0;
|
||||
if (szModule)
|
||||
hModule = LoadLibrary(szModule);
|
||||
|
||||
va_list Ellipsis;
|
||||
va_start(Ellipsis, dwMessageId);
|
||||
|
||||
LPTSTR pszMessage = 0;
|
||||
DWORD dwMessage = 0;
|
||||
if(fSystem) {
|
||||
dwMessage = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM, hModule, dwMessageId,
|
||||
LANG_USER_DEFAULT, (LPTSTR)&pszMessage, 128, &Ellipsis);
|
||||
} else {
|
||||
// we will use a string table.
|
||||
char szString[256];
|
||||
if(LoadString(0, dwMessageId, szString, sizeof(szString)))
|
||||
dwMessage = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_STRING, szString, dwMessageId,
|
||||
LANG_USER_DEFAULT, (LPTSTR)&pszMessage, 256, &Ellipsis);
|
||||
}
|
||||
|
||||
va_end(Ellipsis);
|
||||
|
||||
if (szModule)
|
||||
FreeLibrary(hModule);
|
||||
|
||||
if (dwMessage) {
|
||||
|
||||
Result = printit(pszMessage);
|
||||
LocalFree(pszMessage);
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
|
||||
void LogErrorConsole(LPTSTR szError)
|
||||
{
|
||||
DWORD dwLastError = GetLastError();
|
||||
|
||||
const int cbLastError = 1024;
|
||||
TCHAR szLastError[cbLastError];
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, dwLastError, LANG_USER_DEFAULT,
|
||||
szLastError, cbLastError, 0);
|
||||
|
||||
LPTSTR lpszStrings[2];
|
||||
lpszStrings[0] = szError;
|
||||
lpszStrings[1] = szLastError;
|
||||
|
||||
const int cbErrorString = 1024;
|
||||
TCHAR szErrorString[cbErrorString];
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_HMODULE| FORMAT_MESSAGE_ARGUMENT_ARRAY,
|
||||
0, MSG_ERROR, LANG_USER_DEFAULT,
|
||||
szErrorString, cbErrorString, (va_list*)lpszStrings);
|
||||
|
||||
time_t dwTime;
|
||||
time(&dwTime);
|
||||
char* szTime = ctime(&dwTime);
|
||||
szTime[19] = 0;
|
||||
|
||||
// printf("E %s %s", szTime + 11, szErrorString);
|
||||
char * buf;
|
||||
buf = new char [ 3 + strlen(szTime) - 11 + strlen(szErrorString) + 5 ];
|
||||
sprintf( buf,"E %s %s", szTime + 11, szErrorString);
|
||||
printit(buf);
|
||||
delete [] buf;
|
||||
}
|
||||
|
||||
|
||||
void LogWarningConsole(DWORD dwEvent, LPTSTR szWarning)
|
||||
{
|
||||
DWORD dwLastError = GetLastError();
|
||||
|
||||
const int cbLastError = 1024;
|
||||
TCHAR szLastError[cbLastError];
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, dwLastError, LANG_USER_DEFAULT,
|
||||
szLastError, cbLastError, 0);
|
||||
|
||||
LPTSTR lpszStrings[2];
|
||||
lpszStrings[0] = szWarning;
|
||||
lpszStrings[1] = szLastError;
|
||||
|
||||
const int cbWarningString = 1024;
|
||||
TCHAR szWarningString[cbWarningString];
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_HMODULE| FORMAT_MESSAGE_ARGUMENT_ARRAY,
|
||||
0, dwEvent, LANG_USER_DEFAULT,
|
||||
szWarningString, cbWarningString, (va_list*)lpszStrings);
|
||||
|
||||
time_t dwTime;
|
||||
time(&dwTime);
|
||||
char* szTime = ctime(&dwTime);
|
||||
szTime[19] = 0;
|
||||
|
||||
// printf("W %s %s", szTime + 11, szWarningString);
|
||||
char * buf;
|
||||
buf = new char [ 3 + strlen(szTime) - 11 + strlen(szWarningString) + 5 ];
|
||||
sprintf(buf ,"W %s %s", szTime + 11, szWarningString);
|
||||
printit(buf);
|
||||
delete [] buf;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void LogInfoConsole(DWORD dwEvent, LPTSTR szInformation)
|
||||
{
|
||||
LPTSTR lpszStrings[1];
|
||||
lpszStrings[0] = szInformation;
|
||||
|
||||
const int cbInfoString = 1024;
|
||||
TCHAR szInfoString[cbInfoString];
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_HMODULE| FORMAT_MESSAGE_ARGUMENT_ARRAY,
|
||||
0, dwEvent, LANG_USER_DEFAULT,
|
||||
szInfoString, cbInfoString, (va_list*)lpszStrings);
|
||||
|
||||
time_t dwTime;
|
||||
time(&dwTime);
|
||||
char* szTime = ctime(&dwTime);
|
||||
szTime[19] = 0;
|
||||
|
||||
// printf("I %s %s", szTime + 11, szInfoString);
|
||||
char * buf;
|
||||
buf = new char [ 3 + strlen(szTime) - 11 + strlen(szInfoString) + 5 ];
|
||||
sprintf(buf,"I %s %s", szTime + 11, szInfoString);
|
||||
printit(buf);
|
||||
delete [] buf;
|
||||
|
||||
}
|
||||
|
16
rosapps/net/telnet/src/tnerror.h
Normal file
16
rosapps/net/telnet/src/tnerror.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
#ifndef __TNERROR_H
|
||||
#define __TNERROR_H
|
||||
|
||||
#ifndef __WINDOWS_H
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "tnmsg.h"
|
||||
|
||||
extern int Telnet_Redir;
|
||||
|
||||
int printm(LPTSTR szModule, BOOL fSystem, DWORD dwMessageId, ...);
|
||||
void LogErrorConsole(LPTSTR szError);
|
||||
int printit(const char * it);
|
||||
|
||||
#endif
|
91
rosapps/net/telnet/src/tnetwork.cpp
Normal file
91
rosapps/net/telnet/src/tnetwork.cpp
Normal file
|
@ -0,0 +1,91 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
//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: tnetwork.cpp
|
||||
//
|
||||
// Contents: telnet network module
|
||||
//
|
||||
// Product: telnet
|
||||
//
|
||||
// Revisions: March 18, 1999 Paul Brannan (pbranna@clemson.edu)
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "tnetwork.h"
|
||||
|
||||
void TNetwork::SetSocket(SOCKET s) {
|
||||
socket = s;
|
||||
net_type = TN_NETSOCKET;
|
||||
local_echo = line_mode = 1;
|
||||
}
|
||||
|
||||
void TNetwork::SetPipe(HANDLE pIn, HANDLE pOut) {
|
||||
pipeIn = pIn;
|
||||
pipeOut = pOut;
|
||||
net_type = TN_NETPIPE;
|
||||
local_echo = line_mode = 0;
|
||||
}
|
||||
|
||||
int TNetwork::WriteString(const char *str, const int length) {
|
||||
switch(net_type) {
|
||||
case TN_NETSOCKET:
|
||||
return send(socket, str, length, 0);
|
||||
case TN_NETPIPE:
|
||||
{
|
||||
DWORD dwWritten;
|
||||
if(!WriteFile(pipeOut, str, length, &dwWritten, (LPOVERLAPPED)NULL)) return -1;
|
||||
return dwWritten;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int TNetwork::ReadString (char *str, const int length) {
|
||||
switch(net_type) {
|
||||
case TN_NETSOCKET:
|
||||
return recv(socket, str, length, 0);
|
||||
case TN_NETPIPE:
|
||||
{
|
||||
DWORD dwRead;
|
||||
if(!ReadFile(pipeIn, str, length, &dwRead, (LPOVERLAPPED)NULL)) return -1;
|
||||
return dwRead;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void TNetwork::do_naws(int width, int height) {
|
||||
if(!naws_func) return;
|
||||
char buf[100];
|
||||
int len = (*naws_func)(buf, width, height);
|
||||
WriteString(buf, len);
|
||||
}
|
||||
|
||||
void TNetwork::SetLocalAddress(char *buf) {
|
||||
local_address = new char[strlen(buf) + 1];
|
||||
strcpy(local_address, buf);
|
||||
}
|
61
rosapps/net/telnet/src/tnetwork.h
Normal file
61
rosapps/net/telnet/src/tnetwork.h
Normal file
|
@ -0,0 +1,61 @@
|
|||
// This is a simple class to handle socket connections
|
||||
// (Paul Brannan 6/15/98)
|
||||
|
||||
#ifndef __TNETWORK_H
|
||||
#define __TNETWORK_H
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
// Mingw32 doesn't use winsock.h (Paul Brannan 9/4/98)
|
||||
//#ifdef __MINGW32__
|
||||
//#ifdef __CYGWIN__
|
||||
#include <winsock.h>
|
||||
//#else
|
||||
//#include <Windows32/sockets.h>
|
||||
//#endif
|
||||
//#else
|
||||
//#include <winsock.h>
|
||||
//#endif
|
||||
|
||||
enum NetworkType {TN_NETSOCKET, TN_NETPIPE};
|
||||
|
||||
typedef int(*Naws_func_t)(char *, int, int);
|
||||
|
||||
class TNetwork {
|
||||
private:
|
||||
SOCKET socket;
|
||||
BOOL local_echo; // Paul Brannan 8/25/98
|
||||
BOOL line_mode; // Paul Brannan 12/31/98
|
||||
NetworkType net_type; // Paul Brannan 3/18/99
|
||||
HANDLE pipeIn, pipeOut; // Paul Brannan 3/18/99
|
||||
Naws_func_t naws_func;
|
||||
char *local_address;
|
||||
|
||||
public:
|
||||
TNetwork(SOCKET s = 0): socket(s), local_echo(1), line_mode(1),
|
||||
net_type(TN_NETSOCKET), naws_func((Naws_func_t)NULL),
|
||||
local_address((char *)NULL) {}
|
||||
~TNetwork() {if(local_address) delete local_address;}
|
||||
|
||||
void SetSocket(SOCKET s);
|
||||
SOCKET GetSocket() {return socket;}
|
||||
void SetPipe(HANDLE pIn, HANDLE pOut);
|
||||
void SetNawsFunc(Naws_func_t func) {naws_func = func;}
|
||||
void SetLocalAddress(char *buf);
|
||||
const char* GetLocalAddress() {return local_address;}
|
||||
|
||||
NetworkType get_net_type() {return net_type;}
|
||||
|
||||
int WriteString(const char *str, const int length);
|
||||
int ReadString (char *str, const int length);
|
||||
|
||||
BOOL get_local_echo() {return local_echo;}
|
||||
void set_local_echo(BOOL b) {local_echo = b;}
|
||||
|
||||
BOOL get_line_mode() {return line_mode;}
|
||||
void set_line_mode(BOOL b) {line_mode = b;}
|
||||
|
||||
void do_naws(int width, int height);
|
||||
};
|
||||
|
||||
#endif
|
718
rosapps/net/telnet/src/tnmain.cpp
Normal file
718
rosapps/net/telnet/src/tnmain.cpp
Normal file
|
@ -0,0 +1,718 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
//Telnet Win32 : an ANSI telnet client.
|
||||
//Copyright (C) 1998 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: tnmain.cpp
|
||||
//
|
||||
// Contents: telnet main program
|
||||
//
|
||||
// Product: telnet
|
||||
//
|
||||
// Revisions: August 11, 1998 Thomas Briggs <tbriggs@qmetric.com>
|
||||
// May 14, 1998 Paul Brannan <pbranna@clemson.edu>
|
||||
// 5.April.1997 jbj@nounname.com
|
||||
// 5.Dec.1996 jbj@nounname.com
|
||||
// Version 2.0
|
||||
//
|
||||
// 02.Apr.1995 igor.milavec@uni-lj.si
|
||||
// Original code
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <string.h>
|
||||
#include <locale.h>
|
||||
#include "tnmain.h"
|
||||
#include "tnmisc.h"
|
||||
|
||||
int telCommandLine (Telnet &MyConnection);
|
||||
|
||||
void waitforkey() {
|
||||
HANDLE hConsole = GetStdHandle(STD_INPUT_HANDLE);
|
||||
INPUT_RECORD InputRecord;
|
||||
DWORD dwInput;
|
||||
BOOL done = FALSE;
|
||||
while (!done){
|
||||
WaitForSingleObject( hConsole, INFINITE );
|
||||
if (!ReadConsoleInput(hConsole, &InputRecord, 1, &dwInput)){
|
||||
done = TRUE;
|
||||
continue;
|
||||
}
|
||||
if (InputRecord.EventType == KEY_EVENT &&
|
||||
InputRecord.Event.KeyEvent.bKeyDown )
|
||||
done = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
//char * cfgets ( char * buf, unsigned int length, char pszHistory[][80], int iHistLength){
|
||||
struct cmdHistory * cfgets (char *buf, unsigned int length, struct cmdHistory *cmdhist) {
|
||||
|
||||
HANDLE hConsole = GetStdHandle(STD_INPUT_HANDLE);
|
||||
unsigned int current=0, cursor =0, iEraseLength=0, i;
|
||||
char chr;
|
||||
char temp[2];
|
||||
char temp1[80];
|
||||
|
||||
INPUT_RECORD InputRecord;
|
||||
BOOL done = FALSE;
|
||||
|
||||
temp[1] = 0;
|
||||
buf[0] = '\0';
|
||||
|
||||
if(!ini.get_input_redir()) {
|
||||
while (!done) {
|
||||
DWORD dwInput;
|
||||
int MustRefresh = 0;
|
||||
WaitForSingleObject( hConsole, INFINITE );
|
||||
if (!ReadConsoleInput(hConsole, &InputRecord, 1, &dwInput)){
|
||||
done = TRUE;
|
||||
continue;
|
||||
}
|
||||
MustRefresh = 0;
|
||||
if (InputRecord.EventType == KEY_EVENT &&
|
||||
InputRecord.Event.KeyEvent.bKeyDown ) {
|
||||
|
||||
if(InputRecord.Event.KeyEvent.dwControlKeyState &
|
||||
(LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) {
|
||||
|
||||
switch(InputRecord.Event.KeyEvent.wVirtualKeyCode) {
|
||||
case 'D': // Thomas Briggs 8/11/98
|
||||
buf[0] = '\04';
|
||||
buf[1] = '\0';
|
||||
current = 1;
|
||||
done = true;
|
||||
continue;
|
||||
case 'U': // Paul Brannan 8/11/98
|
||||
buf[0] = '\0';
|
||||
current = 0;
|
||||
cursor = 0;
|
||||
MustRefresh = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (InputRecord.Event.KeyEvent.wVirtualKeyCode) {
|
||||
case VK_UP:
|
||||
// crn@ozemail.com.au
|
||||
if (cmdhist != NULL) {
|
||||
if (!strcmp(buf, ""))
|
||||
strncpy(buf, cmdhist->cmd, 79);
|
||||
else if (cmdhist->prev != NULL) {
|
||||
cmdhist = cmdhist->prev;
|
||||
strncpy(buf, cmdhist->cmd, 79);
|
||||
}
|
||||
current = strlen(buf);
|
||||
}
|
||||
///
|
||||
MustRefresh = 1;
|
||||
break;
|
||||
case VK_DOWN:
|
||||
// crn@ozemail.com.au
|
||||
if (cmdhist != NULL) {
|
||||
if (cmdhist->next != NULL) {
|
||||
cmdhist = cmdhist->next;
|
||||
strncpy(buf, cmdhist->cmd, 79);
|
||||
} else {
|
||||
strncpy(buf, "", 79);
|
||||
}
|
||||
current = strlen(buf);
|
||||
}
|
||||
///
|
||||
MustRefresh = 1;
|
||||
break;
|
||||
case VK_RIGHT: //crn@ozemail.com.au (added ctrl+arrow)
|
||||
if (cursor < current)
|
||||
if (InputRecord.Event.KeyEvent.dwControlKeyState &
|
||||
(LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) {
|
||||
unsigned int i,j;
|
||||
for (j = cursor; j <= current; j++)
|
||||
if (buf[j+1] == ' ' || (j+1)==current)
|
||||
break;
|
||||
for (i = ++j; i <= current; i++)
|
||||
if (buf[i] != ' ' || i == current) {
|
||||
cursor = i == current ? --i : i;
|
||||
break;
|
||||
}
|
||||
} else
|
||||
cursor++;
|
||||
MustRefresh = 1;
|
||||
break;
|
||||
case VK_LEFT: //crn@ozemail.com.au (added ctrl+arrow)
|
||||
if (cursor > 0)
|
||||
if(InputRecord.Event.KeyEvent.dwControlKeyState &
|
||||
(LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) {
|
||||
int i,j;
|
||||
for (j = cursor; j >= 0; j--)
|
||||
if (buf[j-1] != ' ')
|
||||
break;
|
||||
for (i = --j; i >= 0; i--)
|
||||
if (buf[i] == ' ' || i == 0) {
|
||||
cursor = !i ? i : ++i;
|
||||
break;
|
||||
}
|
||||
} else
|
||||
cursor--;
|
||||
MustRefresh = 1;
|
||||
break;
|
||||
case VK_HOME:
|
||||
if (cursor>0) cursor = 0;
|
||||
MustRefresh = 1;
|
||||
break;
|
||||
case VK_END:
|
||||
if (cursor<current) cursor = current;
|
||||
MustRefresh = 1;
|
||||
break;
|
||||
case VK_DELETE:
|
||||
if (current > 0 && current > cursor) {
|
||||
strcpy(&buf[cursor],&buf[cursor+1]);
|
||||
current--;
|
||||
buf[current] = 0;
|
||||
printit("\r");
|
||||
for (i = 0; i < current+strlen("telnet>")+1 ;i++)
|
||||
printit(" ");
|
||||
}
|
||||
MustRefresh = 1;
|
||||
break;
|
||||
case VK_BACK:
|
||||
if (cursor > 0 ) {
|
||||
strcpy(&buf[cursor-1],&buf[cursor]);
|
||||
current--;
|
||||
cursor--;
|
||||
buf[current] = 0;
|
||||
printit("\r");
|
||||
for (i = 0; i < current+strlen("telnet>")+1 ;i++)
|
||||
printit(" ");
|
||||
}
|
||||
MustRefresh = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
chr = InputRecord.Event.KeyEvent.uChar.AsciiChar;
|
||||
if (chr == '\r') {
|
||||
done = TRUE;
|
||||
continue;
|
||||
}
|
||||
if (current >= length-1){
|
||||
done = TRUE;
|
||||
continue;
|
||||
}
|
||||
if ( isprint (chr) ){
|
||||
strncpy(temp1,&buf[cursor],79);
|
||||
strncpy(&buf[cursor+1],temp1,79-(cursor+1));
|
||||
buf[cursor++]=chr;
|
||||
current++;
|
||||
buf[current] = 0;
|
||||
MustRefresh = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (MustRefresh == 1)
|
||||
{
|
||||
printit("\rtelnet");
|
||||
for (i = 0; i <= iEraseLength ;i++)
|
||||
printit(" ");
|
||||
printit("\rtelnet>");
|
||||
printit(buf);
|
||||
iEraseLength = strlen(buf);
|
||||
for (i = 0; i < current-cursor; i++)
|
||||
printit("\b");
|
||||
}
|
||||
}
|
||||
}
|
||||
buf[current] = 0;
|
||||
if (strcmp(buf, "")) {
|
||||
if (cmdhist == NULL) {
|
||||
cmdhist = new struct cmdHistory;
|
||||
if (cmdhist == NULL) {
|
||||
printit ("\nUnable to allocate memory for history buffer -- use the \"flush\" command to clear the buffer.\n");
|
||||
return cmdhist;
|
||||
}
|
||||
strncpy(cmdhist->cmd, buf, 79);
|
||||
cmdhist->next = NULL;
|
||||
cmdhist->prev = NULL;
|
||||
} else {
|
||||
while (cmdhist->next != NULL) // move to the end of the list
|
||||
cmdhist = cmdhist->next;
|
||||
cmdhist->next = new struct cmdHistory;
|
||||
if (cmdhist->next == NULL) {
|
||||
printit ("\nUnable to allocate memory for history buffer -- use the \"flush\" command to clear the buffer.\n");
|
||||
return cmdhist;
|
||||
}
|
||||
cmdhist->next->prev = cmdhist; // previous is where we are now
|
||||
cmdhist = cmdhist->next;
|
||||
strncpy(cmdhist->cmd, buf, 79);
|
||||
cmdhist->next = NULL;
|
||||
}
|
||||
while (cmdhist->next)
|
||||
cmdhist = cmdhist->next;
|
||||
}
|
||||
return cmdhist;
|
||||
///
|
||||
} else {
|
||||
WaitForSingleObject( hConsole, INFINITE );
|
||||
DWORD dwInput;
|
||||
DWORD OldMode;
|
||||
GetConsoleMode(hConsole, &OldMode);
|
||||
SetConsoleMode(hConsole,
|
||||
OldMode &~ (ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT) );
|
||||
while (ReadFile(hConsole, &chr, 1, &dwInput, NULL)) {
|
||||
if (chr == '\r') {
|
||||
temp[0] = chr;
|
||||
printit(&temp[0]);
|
||||
break;
|
||||
}
|
||||
if (chr == '\b' && current > 0) {
|
||||
current--;
|
||||
printit("\b \b");
|
||||
}
|
||||
if (current >= length-1){
|
||||
break;
|
||||
}
|
||||
if ( isprint (chr) ){
|
||||
temp[0] = chr;
|
||||
printit(&temp[0]);
|
||||
buf[current++]=chr;
|
||||
}
|
||||
}
|
||||
buf[current] = 0;
|
||||
SetConsoleMode(hConsole, OldMode);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// AVS ** for fix bug in command 'keys load keymapname' without file
|
||||
// static char keyfile[MAX_PATH*2];
|
||||
|
||||
int main(int ArgC, char* ArgV[]) {
|
||||
|
||||
CONSOLE_SCREEN_BUFFER_INFO ConsoleScreenBufferInfo;
|
||||
GetConsoleScreenBufferInfo(
|
||||
GetStdHandle(STD_OUTPUT_HANDLE),
|
||||
&ConsoleScreenBufferInfo
|
||||
);
|
||||
|
||||
char *k;
|
||||
char startdir[MAX_PATH*2];
|
||||
char exename[MAX_PATH];
|
||||
|
||||
// strncpy(startdir, ArgV[0],MAX_PATH);
|
||||
// This should be more accurate than using argv[0] (Paul Brannan 9/16/98)
|
||||
GetModuleFileName(NULL, startdir, sizeof(startdir));
|
||||
|
||||
// Get the current console title so it can be set later
|
||||
// ("Pedro A. Aranda Gutiérrez" <paag@coppi.tid.es>)
|
||||
TCHAR ConsoleTitle[255];
|
||||
GetConsoleTitle(ConsoleTitle, sizeof(ConsoleTitle));
|
||||
|
||||
k = strrchr(startdir, '\\');
|
||||
if (k == NULL){ // if the \ character is not found...
|
||||
strcpy(exename, startdir);
|
||||
strcpy(startdir,""); // set the path to nothing
|
||||
} else {
|
||||
// end the string after the last '\' to get rid of the file name
|
||||
strcpy(exename, k+1);
|
||||
k[1] = 0;
|
||||
}
|
||||
|
||||
printm(0, FALSE, MSG_COPYRIGHT);
|
||||
printm(0, FALSE, MSG_COPYRIGHT_1);
|
||||
|
||||
// set up the ini class
|
||||
ini.init(startdir, exename);
|
||||
|
||||
// Process the command line arguments and connect to a host if necessary
|
||||
if(ini.Process_Params(ArgC, ArgV)) {
|
||||
const char *szHost = ini.get_host();
|
||||
const char *strPort = ini.get_port();
|
||||
if(!*szHost) {
|
||||
Telnet MyConnection;
|
||||
while(telCommandLine(MyConnection));
|
||||
} else {
|
||||
Telnet MyConnection;
|
||||
if(MyConnection.Open(szHost, strPort) == TNPROMPT) {
|
||||
// still connected
|
||||
printit("\n");
|
||||
telCommandLine(MyConnection);
|
||||
}
|
||||
}
|
||||
}
|
||||
//// (Paul Brannan 5/14/98)
|
||||
|
||||
if(ini.get_term_width() != -1 || ini.get_term_height() != -1) {
|
||||
SetConsoleScreenBufferSize(
|
||||
GetStdHandle(STD_OUTPUT_HANDLE), // handle of console screen buffer
|
||||
ConsoleScreenBufferInfo.dwSize // new size in character rows and cols.
|
||||
);
|
||||
SetConsoleWindowInfo(
|
||||
GetStdHandle(STD_OUTPUT_HANDLE), // handle of console screen buffer
|
||||
TRUE, // coordinate type flag
|
||||
&ConsoleScreenBufferInfo.srWindow // address of new window rectangle
|
||||
);
|
||||
}
|
||||
SetConsoleTextAttribute(
|
||||
GetStdHandle(STD_OUTPUT_HANDLE), // handle of console screen buffer
|
||||
ConsoleScreenBufferInfo.wAttributes // text and background colors
|
||||
);
|
||||
|
||||
// Restore the original console title
|
||||
// ("Pedro A. Aranda Gutiérrez" <paag@coppi.tid.es>)
|
||||
SetConsoleTitle(ConsoleTitle);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// AVS
|
||||
enum {
|
||||
BAD_USAGE = -3,
|
||||
EMPTY_LINE = -2,
|
||||
INVALID_CMD = -1,
|
||||
__FIRST_COMMAND = 0,
|
||||
|
||||
OPEN = __FIRST_COMMAND,
|
||||
CLOSE,
|
||||
KEYS,
|
||||
QUIT,
|
||||
HELP,
|
||||
HELP2, // there is way for synonims
|
||||
K_LOAD, // subcommand of 'keys'
|
||||
K_SWITCH, // subcommand of 'keys'
|
||||
K_DISPLAY, // subcommand of 'keys'
|
||||
|
||||
SET, // Paul Brannan 5/30/98
|
||||
|
||||
SUSPEND,
|
||||
FASTQUIT, // Thomas Briggs 8/11/98
|
||||
CMD_HISTORY, // crn@ozemail.com.au
|
||||
CLEAR_HISTORY, // crn@ozemail.com.au
|
||||
|
||||
ALIASES, // Paul Brannan 1/1/99
|
||||
|
||||
__COMMAND_LIST_SIZE // must be last
|
||||
};
|
||||
|
||||
|
||||
struct command {
|
||||
char* cmd; // command
|
||||
int minLen, // minimal length for match
|
||||
minParms, // minimal count of parms
|
||||
maxParms; // maximal -/- (negative disables)
|
||||
int isSubCmd, // is a subcommand - number of wich command
|
||||
haveSubCmd; // have subcommands? 0 or 1
|
||||
char* usage; // text of usage
|
||||
};
|
||||
|
||||
command cmdList[__COMMAND_LIST_SIZE] = {
|
||||
{"open", 1, 1, 2, -1, 0, "o[pen] host [port]\n"},
|
||||
{"close", 2, 0, 0, -1, 0, NULL},
|
||||
{"keys", 2, 1, 3, -1, 1, "ke[ys] l[oad] keymapname [file]\n"
|
||||
"ke[ys] d[isplay]\n"
|
||||
"ke[ys] s[witch] number\n"},
|
||||
// Ioannou : i change it to q, to be more compatible with unix telnet
|
||||
{"quit", 1, 0, 0, -1, 0, NULL}, // must type it exactly
|
||||
{"?", 1, 0, 0, -1, 0, NULL},
|
||||
{"help", 1, 0, 0, -1, 0, NULL},
|
||||
{"load", 1, 1, 2, KEYS, 0, NULL},
|
||||
{"switch", 1, 1, 1, KEYS, 0, NULL},
|
||||
{"display", 1, 0, 0, KEYS, 0, NULL},
|
||||
// Paul Brannan 5/30/98
|
||||
{"set", 3, 0, 2, -1, 0, "set will display available groups.\n"
|
||||
"set groupname will display all variables/values in a group.\n"
|
||||
"set [variable [value]] will set variable to value.\n"},
|
||||
// Thomas Briggs 8/11/98
|
||||
{"z", 1, 0, 0, -1, 0, "suspend telnet\n"},
|
||||
{"\04", 1, 0, 0, -1, 0, NULL},
|
||||
// crn@ozemail.com.au
|
||||
{"history", 2, 0, 0, -1, 0, "show command history"},
|
||||
{"flush", 2, 0, 0, -1, 0, "flush history buffer"},
|
||||
// Paul Brannan 1/1/99
|
||||
{"aliases", 5, 0, 0, -1, 0, NULL}
|
||||
};
|
||||
|
||||
// a maximal count of parms
|
||||
#define MAX_PARM_COUNT 3
|
||||
#define MAX_TOKEN_COUNT (MAX_PARM_COUNT+2)
|
||||
|
||||
static int cmdMatch(const char* cmd, const char* token, int tokenLen, int minM) {
|
||||
if ( tokenLen < minM ) return 0;
|
||||
// The (unsigned) gets rid of a compiler warning (Paul Brannan 5/25/98)
|
||||
if ( (unsigned)tokenLen > strlen(cmd) ) return 0;
|
||||
if ( strcmp(cmd,token) == 0 ) return 1;
|
||||
|
||||
int i;
|
||||
for ( i = 0; i < minM; i++ ) if ( cmd[i] != token[i] ) return 0;
|
||||
|
||||
for ( i = minM; i < tokenLen; i++ ) if ( cmd[i] != token[i] ) return 0;
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
static void printUsage(int cmd) {
|
||||
if ( cmdList[cmd].usage != NULL ) {
|
||||
printit(cmdList[cmd].usage);
|
||||
return;
|
||||
};
|
||||
if ( cmdList[cmd].isSubCmd >= 0 ) {
|
||||
printUsage(cmdList[cmd].isSubCmd);
|
||||
return;
|
||||
}
|
||||
printm(0, FALSE, MSG_BADUSAGE);
|
||||
};
|
||||
|
||||
int tokenizeCommand(char* szCommand, int& argc, char** argv) {
|
||||
char* tokens[MAX_TOKEN_COUNT];
|
||||
char* p;
|
||||
int args = 0;
|
||||
|
||||
if(!szCommand || !*szCommand) return EMPTY_LINE;
|
||||
|
||||
// Removed strtok to handle tokens with spaces; this is handled with
|
||||
// quotes. (Paul Brannan 3/18/99)
|
||||
char *token_start = szCommand;
|
||||
for(p = szCommand;; p++) {
|
||||
if(*p == '\"') {
|
||||
char *tmp = p;
|
||||
for(p++; *p != '\"' && *p != 0; p++); // Find the next quote
|
||||
if(*p != 0) strcpy(p, p + 1); // Remove quote#2
|
||||
strcpy(tmp, tmp + 1); // Remove quote#1
|
||||
}
|
||||
if(*p == 0 || *p == ' ' || *p == '\t') {
|
||||
tokens[args] = token_start;
|
||||
args++;
|
||||
if(args >= MAX_TOKEN_COUNT) break; // Break if too many args
|
||||
token_start = p + 1;
|
||||
if(*p == 0) break;
|
||||
*p = 0;
|
||||
}
|
||||
}
|
||||
// while ( (p = strtok((args?NULL:szCommand), " \t")) != NULL && args < MAX_TOKEN_COUNT ) {
|
||||
// tokens[args] = p;
|
||||
// args++;
|
||||
// };
|
||||
|
||||
if ( !args ) return EMPTY_LINE;
|
||||
argc = args - 1;
|
||||
args = 0;
|
||||
int curCmd = -1;
|
||||
int ok = -1;
|
||||
while ( ok < 0 ) {
|
||||
int tokenLen = strlen(tokens[args]);
|
||||
int match = 0;
|
||||
for ( int i = 0; i<__COMMAND_LIST_SIZE; i++ ) {
|
||||
if ( cmdMatch(cmdList[i].cmd, tokens[args], tokenLen, cmdList[i].minLen) ) {
|
||||
if (argc < cmdList[i].minParms || argc > cmdList[i].maxParms) {
|
||||
printUsage(i);
|
||||
return BAD_USAGE;
|
||||
};
|
||||
if ( cmdList[i].haveSubCmd && curCmd == cmdList[i].isSubCmd) {
|
||||
curCmd = i;
|
||||
args++;
|
||||
argc--;
|
||||
match = 1;
|
||||
break;
|
||||
};
|
||||
if ( curCmd == cmdList[i].isSubCmd ) {
|
||||
ok = i;
|
||||
match = 1;
|
||||
break;
|
||||
};
|
||||
printUsage(i);
|
||||
return BAD_USAGE;
|
||||
};
|
||||
};
|
||||
if ( !match ) {
|
||||
if ( curCmd < 0 ) return INVALID_CMD;
|
||||
printUsage(curCmd);
|
||||
return -3;
|
||||
};
|
||||
};
|
||||
|
||||
for ( int i = 0; i<argc; i++ ) {
|
||||
argv[i] = tokens[i+args+1];
|
||||
};
|
||||
return ok;
|
||||
|
||||
};
|
||||
|
||||
int telCommandLine (Telnet &MyConnection){
|
||||
#define HISTLENGTH 25
|
||||
int i, retval;
|
||||
char* Parms[MAX_PARM_COUNT];
|
||||
char szCommand[80];
|
||||
int bDone = 0;
|
||||
char *extitle, *newtitle;
|
||||
struct cmdHistory *cmdhist;
|
||||
cmdhist = NULL;
|
||||
|
||||
// printit("\n"); // crn@ozemail.com.au 14/12/98
|
||||
while (!bDone){
|
||||
// printit("\n"); // Paul Brannan 5/25/98
|
||||
printit( "telnet>");
|
||||
cmdhist = cfgets (szCommand, 79, cmdhist);
|
||||
printit( "\n");
|
||||
|
||||
strlwr(szCommand); // convert command line to lower
|
||||
// i = sscanf(szCommand,"%80s %80s %80s %80s", szCmd, szArg1, szArg2, szArg3);
|
||||
switch ( tokenizeCommand(szCommand, i, Parms) ) {
|
||||
case BAD_USAGE: break;
|
||||
case EMPTY_LINE:
|
||||
if(MyConnection.Resume() == TNPROMPT) {
|
||||
printit("\n");
|
||||
break;
|
||||
}
|
||||
else
|
||||
return 1;
|
||||
case INVALID_CMD:
|
||||
printm(0, FALSE, MSG_INVCMD);
|
||||
break;
|
||||
case OPEN:
|
||||
if (i == 1)
|
||||
retval = MyConnection.Open(Parms[0], "23");
|
||||
else
|
||||
retval = MyConnection.Open(Parms[0], Parms[1]);
|
||||
if(retval != TNNOCON && retval != TNPROMPT) return 1;
|
||||
if(retval == TNPROMPT) printit("\n");
|
||||
break;
|
||||
case CLOSE:
|
||||
MyConnection.Close();
|
||||
break;
|
||||
case FASTQUIT: // Thomas Briggs 8/11/98
|
||||
case QUIT:
|
||||
MyConnection.Close();
|
||||
bDone = 1;
|
||||
break;
|
||||
case HELP:
|
||||
case HELP2:
|
||||
printm(0, FALSE, MSG_HELP);
|
||||
printm(0, FALSE, MSG_HELP_1);
|
||||
break;
|
||||
// case KEYS: we should never get it
|
||||
case K_LOAD:
|
||||
if ( i == 1 ) {
|
||||
// Ioannou : changed to ini.get_keyfile()
|
||||
if(MyConnection.LoadKeyMap( ini.get_keyfile(), Parms[0]) != 1)
|
||||
printit("Error loading keymap.\n");
|
||||
break;
|
||||
};
|
||||
if(MyConnection.LoadKeyMap( Parms[1], Parms[0]) != 1)
|
||||
printit("Error loading keymap.\n");
|
||||
break;
|
||||
case K_DISPLAY:
|
||||
MyConnection.DisplayKeyMap();
|
||||
break;
|
||||
case K_SWITCH:
|
||||
MyConnection.SwitchKeyMap(atoi(Parms[0]));
|
||||
break;
|
||||
|
||||
// Paul Brannan 5/30/98
|
||||
case SET:
|
||||
if(i == 0) {
|
||||
printit("Available groups:\n"); // Print out groups
|
||||
ini.print_groups(); // (Paul Brannan 9/3/98)
|
||||
} else if(i == 1) {
|
||||
ini.print_vars(Parms[0]);
|
||||
} else if(i >= 2) {
|
||||
ini.set_value(Parms[0], Parms[1]);
|
||||
// FIX ME !!! Ioannou: here we must call the parser routine for
|
||||
// wrap line, not the ini.set_value
|
||||
// something like Parser.ConLineWrap(Wrap_Line);
|
||||
}
|
||||
break;
|
||||
|
||||
case SUSPEND: // Thomas Briggs 8/11/98
|
||||
|
||||
// remind the user we're suspended -crn@ozemail.com.au 15/12/98
|
||||
extitle = new char[128];
|
||||
GetConsoleTitle (extitle, 128);
|
||||
|
||||
newtitle = new char[128+sizeof("[suspended]")];
|
||||
strcpy(newtitle, extitle);
|
||||
strncat(newtitle, "[suspended]", 128+sizeof("[suspended]"));
|
||||
if(ini.get_set_title()) SetConsoleTitle (newtitle);
|
||||
delete[] newtitle;
|
||||
|
||||
if (getenv("comspec") == NULL) {
|
||||
switch (GetWin32Version()) {
|
||||
case 2: // 'cmd' is faster than 'command' in NT -crn@ozemail.com.au
|
||||
system ("cmd");
|
||||
break;
|
||||
default:
|
||||
system ("command");
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
system(getenv("comspec"));
|
||||
}
|
||||
|
||||
if(ini.get_set_title()) SetConsoleTitle (extitle);
|
||||
delete[] extitle;
|
||||
///
|
||||
|
||||
break;
|
||||
|
||||
case CMD_HISTORY: //crn@ozemail.com.au
|
||||
if (cmdhist != NULL) {
|
||||
while (cmdhist->prev != NULL)
|
||||
cmdhist = cmdhist->prev; //rewind
|
||||
printf ("Command history:\n");
|
||||
while (1) {
|
||||
printf ("\t%s\n", cmdhist->cmd);
|
||||
|
||||
if (cmdhist->next != NULL)
|
||||
cmdhist = cmdhist->next;
|
||||
else
|
||||
break;
|
||||
}
|
||||
} else
|
||||
printf ("No command history available.\n");
|
||||
|
||||
break;
|
||||
|
||||
case CLEAR_HISTORY: //crn@ozemail.com.au
|
||||
if (cmdhist != NULL) {
|
||||
while (cmdhist->next != NULL)
|
||||
cmdhist = cmdhist->next; //fast forward
|
||||
while (cmdhist->prev != NULL) {
|
||||
cmdhist = cmdhist->prev;
|
||||
delete cmdhist->next;
|
||||
}
|
||||
delete cmdhist;
|
||||
cmdhist = NULL;
|
||||
printf ("Command history cleared.\n");
|
||||
} else
|
||||
printf ("No command history available.\n");
|
||||
|
||||
case ALIASES: // Paul Brannan 1/1/99
|
||||
ini.print_aliases();
|
||||
break;
|
||||
|
||||
default: // paranoik
|
||||
printm(0, FALSE, MSG_INVCMD);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
19
rosapps/net/telnet/src/tnmain.h
Normal file
19
rosapps/net/telnet/src/tnmain.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
#ifndef __TNMAIN_H
|
||||
#define __TNMAIN_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <process.h>
|
||||
#include "tncon.h"
|
||||
#include "tnclass.h"
|
||||
#include "ttelhndl.h"
|
||||
#include "tnerror.h"
|
||||
// Paul Brannan 5/25/98
|
||||
#include "tnconfig.h"
|
||||
|
||||
struct cmdHistory {
|
||||
char cmd[80];
|
||||
struct cmdHistory *next;
|
||||
struct cmdHistory *prev;
|
||||
};
|
||||
|
||||
#endif
|
185
rosapps/net/telnet/src/tnmisc.cpp
Normal file
185
rosapps/net/telnet/src/tnmisc.cpp
Normal file
|
@ -0,0 +1,185 @@
|
|||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
|
||||
#include "tnmisc.h"
|
||||
|
||||
// from the PVAX (http://www.ccas.ru/~posp/popov/spawn.htm)
|
||||
// Create a process with pipes to stdin/out/err
|
||||
BOOL CreateHiddenConsoleProcess(LPCTSTR szChildName, PROCESS_INFORMATION* ppi,
|
||||
LPHANDLE phInWrite, LPHANDLE phOutRead,
|
||||
LPHANDLE phErrRead) {
|
||||
BOOL fCreated;
|
||||
STARTUPINFO si;
|
||||
SECURITY_ATTRIBUTES sa;
|
||||
HANDLE hInRead;
|
||||
HANDLE hOutWrite;
|
||||
HANDLE hErrWrite;
|
||||
|
||||
// Create pipes
|
||||
// initialize security attributes for handle inheritance (for WinNT)
|
||||
sa.nLength = sizeof( sa );
|
||||
sa.bInheritHandle = TRUE;
|
||||
sa.lpSecurityDescriptor = NULL;
|
||||
|
||||
// create STDIN pipe
|
||||
if( !CreatePipe( &hInRead, phInWrite, &sa, 0 ))
|
||||
goto error;
|
||||
|
||||
// create STDOUT pipe
|
||||
if( !CreatePipe( phOutRead, &hOutWrite, &sa, 0 ))
|
||||
goto error;
|
||||
|
||||
// create STDERR pipe
|
||||
if( !CreatePipe( phErrRead, &hErrWrite, &sa, 0 ))
|
||||
goto error;
|
||||
|
||||
// process startup information
|
||||
memset( &si, 0, sizeof( si ));
|
||||
si.cb = sizeof( si );
|
||||
si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
|
||||
// child process' console must be hidden for Win95 compatibility
|
||||
si.wShowWindow = SW_HIDE;
|
||||
// assign "other" sides of pipes
|
||||
si.hStdInput = hInRead;
|
||||
si.hStdOutput = hOutWrite;
|
||||
si.hStdError = hErrWrite;
|
||||
|
||||
// Create a child process (suspended)
|
||||
fCreated = CreateProcess( NULL,
|
||||
(LPTSTR)szChildName,
|
||||
NULL,
|
||||
NULL,
|
||||
TRUE,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
&si,
|
||||
ppi );
|
||||
|
||||
if( !fCreated )
|
||||
goto error;
|
||||
|
||||
CloseHandle( hInRead );
|
||||
CloseHandle( hOutWrite );
|
||||
CloseHandle( hErrWrite );
|
||||
|
||||
return TRUE;
|
||||
|
||||
error:
|
||||
CloseHandle( hInRead );
|
||||
CloseHandle( hOutWrite );
|
||||
CloseHandle( hErrWrite );
|
||||
CloseHandle( ppi->hProcess );
|
||||
CloseHandle( ppi->hThread );
|
||||
|
||||
hInRead =
|
||||
hOutWrite =
|
||||
hErrWrite =
|
||||
ppi->hProcess =
|
||||
ppi->hThread = INVALID_HANDLE_VALUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL SpawnProcess(char *cmd_line, PROCESS_INFORMATION *pi) {
|
||||
STARTUPINFO si;
|
||||
|
||||
memset(&si, 0, sizeof(si));
|
||||
si.cb = sizeof(si);
|
||||
|
||||
return CreateProcess(cmd_line, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS,
|
||||
CREATE_NEW_CONSOLE, NULL, NULL, &si, pi);
|
||||
}
|
||||
|
||||
// crn@ozemail.com.au
|
||||
int GetWin32Version(void) {
|
||||
// return win32 version; 0 = Win32s, 1 = Win95, 2 = WinNT, 3 = Unknown -crn@ozemail.com.au
|
||||
LPOSVERSIONINFO osv;
|
||||
DWORD retval;
|
||||
|
||||
osv = new OSVERSIONINFO;
|
||||
|
||||
osv->dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
|
||||
GetVersionEx (osv);
|
||||
retval = osv->dwPlatformId;
|
||||
delete osv;
|
||||
return (retval);
|
||||
}
|
||||
|
||||
// Paul Brannan 8/7/98
|
||||
// This code is from Michael 'Hacker' Krelin (author of KINSole)
|
||||
// (slightly modified)
|
||||
HWND GetConsoleWindow() {
|
||||
DWORD pid = GetCurrentProcessId(), wpid;
|
||||
char title[512], *t = title;
|
||||
HWND hrv = NULL;
|
||||
|
||||
#ifndef __BORLANDC__ // Ioannou Dec. 8, 1998
|
||||
if(!GetConsoleTitle(title, sizeof(title))) t = NULL;
|
||||
|
||||
for(;;) {
|
||||
if((hrv = FindWindowEx(NULL, hrv, "tty", t)) == NULL) break;
|
||||
if(!GetWindowThreadProcessId(hrv, &wpid)) continue;
|
||||
if(wpid == pid) return hrv;
|
||||
}
|
||||
#endif
|
||||
|
||||
return GetForegroundWindow();
|
||||
}
|
||||
|
||||
// Sets the icon of the console window to hIcon
|
||||
// If hIcon is 0, then use a default icon
|
||||
// hConsoleWindow must be set before calling SetIcon
|
||||
bool SetIcon(HWND hConsoleWindow, HANDLE hIcon, LPARAM *pOldBIcon, LPARAM *pOldSIcon,
|
||||
const char *icondir) {
|
||||
if(!hConsoleWindow) return false;
|
||||
|
||||
// FIX ME!!! The LoadIcon code should work with any compiler!
|
||||
// (Paul Brannan 12/17/98)
|
||||
#ifndef __BORLANDC__ // Ioannou Dec. 8, 1998
|
||||
if(!hIcon) {
|
||||
char filename[128]; // load from telnet.ico
|
||||
strncpy(filename, icondir, sizeof(filename));
|
||||
strncat(filename, "telnet.ico", sizeof(filename));
|
||||
filename[sizeof(filename) - 1] = 0;
|
||||
|
||||
// Note: loading the icon from a file doesn't work on NT
|
||||
// There is no LoadImage in Borland headers - only LoadIcon
|
||||
hIcon = LoadImage(NULL, filename, IMAGE_ICON, 0, 0, LR_DEFAULTSIZE +
|
||||
LR_LOADFROMFILE);
|
||||
}
|
||||
#else
|
||||
// load the icon from the resource file -crn@ozemail.com.au 16/12/98
|
||||
if(!hIcon) {
|
||||
hIcon = LoadIcon ((HANDLE)GetWindowLong(hConsoleWindow,
|
||||
GWL_HINSTANCE), "TELNETICON");
|
||||
}
|
||||
#endif
|
||||
|
||||
if(hIcon) {
|
||||
#ifdef ICON_BIG
|
||||
*pOldBIcon = SendMessage(hConsoleWindow, WM_SETICON, ICON_BIG,
|
||||
(LPARAM)hIcon);
|
||||
#endif
|
||||
#ifdef ICON_SMALL
|
||||
*pOldSIcon = SendMessage(hConsoleWindow, WM_SETICON, ICON_SMALL,
|
||||
(LPARAM)hIcon);
|
||||
#endif
|
||||
return true;
|
||||
} else {
|
||||
// Otherwise we get a random icon at exit! (Paul Brannan 9/13/98)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Allows SetIcon to be called again by resetting the current icon
|
||||
// Added 12/17/98 by Paul Brannan
|
||||
void ResetIcon(HWND hConsoleWindow, LPARAM oldBIcon, LPARAM oldSIcon) {
|
||||
#ifdef ICON_BIG
|
||||
SendMessage(hConsoleWindow, WM_SETICON, ICON_BIG, (LPARAM)oldBIcon);
|
||||
#endif
|
||||
#ifdef ICON_SMALL
|
||||
SendMessage(hConsoleWindow, WM_SETICON, ICON_SMALL, (LPARAM)oldSIcon);
|
||||
#endif
|
||||
}
|
18
rosapps/net/telnet/src/tnmisc.h
Normal file
18
rosapps/net/telnet/src/tnmisc.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
#ifndef __TNMISC_H
|
||||
#define __TNMISC_H
|
||||
|
||||
// Process-related functions
|
||||
BOOL CreateHiddenConsoleProcess(LPCTSTR szChildName, PROCESS_INFORMATION* ppi,
|
||||
LPHANDLE phInWrite, LPHANDLE phOutRead,
|
||||
LPHANDLE phErrRead);
|
||||
BOOL SpawnProcess(char *cmd_line, PROCESS_INFORMATION *pi);
|
||||
|
||||
int GetWin32Version(void);
|
||||
|
||||
HWND GetConsoleWindow();
|
||||
|
||||
bool SetIcon(HWND hConsoleWindow, HANDLE hIcon, LPARAM *pOldBIcon, LPARAM *pOldSIcon,
|
||||
const char *icondir);
|
||||
void ResetIcon(HWND hConsoleWindow, LPARAM oldBIcon, LPARAM oldSIcon);
|
||||
|
||||
#endif
|
108
rosapps/net/telnet/src/tnmsg.h
Normal file
108
rosapps/net/telnet/src/tnmsg.h
Normal file
|
@ -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
|
24
rosapps/net/telnet/src/tparams.h
Normal file
24
rosapps/net/telnet/src/tparams.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
#ifndef __THREADPARAMS
|
||||
#define __THREADPARAMS
|
||||
|
||||
#include "ttelhndl.h"
|
||||
|
||||
typedef struct {
|
||||
HANDLE hExit;
|
||||
HANDLE hPause, hUnPause;
|
||||
volatile int *bNetPaused;
|
||||
volatile int *bNetFinished;
|
||||
volatile int *bNetFinish;
|
||||
} NetParams;
|
||||
|
||||
// We could make TelHandler a pointer rather than a reference, but making it
|
||||
// a reference forces us to initialize it when it is created, thus avoiding
|
||||
// a possible segfault (Paul Brannan 6/15/98)
|
||||
class TelThreadParams {
|
||||
public:
|
||||
TelThreadParams(TTelnetHandler &RefTelHandler): TelHandler(RefTelHandler) {}
|
||||
NetParams p;
|
||||
TTelnetHandler &TelHandler;
|
||||
};
|
||||
|
||||
#endif
|
49
rosapps/net/telnet/src/tparser.h
Normal file
49
rosapps/net/telnet/src/tparser.h
Normal file
|
@ -0,0 +1,49 @@
|
|||
// A TParser is a class for parsing input and formatting it (presumabyl for
|
||||
// display on the screen). All parsers are derived from the TParser class,
|
||||
// in order to facilitate extending telnet to include other kinds of
|
||||
// output. Currently, only one parser is implemented, the ANSI parser.
|
||||
// A TParser includes:
|
||||
// - A ParseBuffer function, which takes as parameters start and end
|
||||
// pointers. It returns a pointer to the last character parsed plus 1.
|
||||
// The start pointer is the beginning of the buffer, and the end
|
||||
// pointer is one character after the end of the buffer.
|
||||
// - An Init() function, which will re-initialize the parser when
|
||||
// necessary.
|
||||
|
||||
#ifndef __TPARSER_H
|
||||
#define __TPARSER_H
|
||||
|
||||
#include "tconsole.h"
|
||||
#include "keytrans.h"
|
||||
#include "tscroll.h"
|
||||
#include "tnetwork.h"
|
||||
#include "tcharmap.h"
|
||||
|
||||
class TParser {
|
||||
public:
|
||||
TParser(TConsole &RefConsole, KeyTranslator &RefKeyTrans,
|
||||
TScroller &RefScroller, TNetwork &RefNetwork, TCharmap &RefCharmap) :
|
||||
Console(RefConsole), KeyTrans(RefKeyTrans), Scroller (RefScroller),
|
||||
Network(RefNetwork), Charmap(RefCharmap) {}
|
||||
virtual ~TParser() {}
|
||||
|
||||
/* TParser& operator= (const TParser &p) {
|
||||
Console = p.Console;
|
||||
KeyTrans = p.KeyTrans;
|
||||
Scroller = p.Scroller;
|
||||
Network = p.Network;
|
||||
return *this;
|
||||
}*/
|
||||
|
||||
virtual char *ParseBuffer(char *pszBuffer, char *pszBufferEnd) = 0;
|
||||
virtual void Init() = 0;
|
||||
|
||||
protected:
|
||||
TConsole &Console;
|
||||
KeyTranslator &KeyTrans;
|
||||
TScroller &Scroller;
|
||||
TNetwork &Network;
|
||||
TCharmap &Charmap;
|
||||
};
|
||||
|
||||
#endif
|
62
rosapps/net/telnet/src/tscript.cpp
Normal file
62
rosapps/net/telnet/src/tscript.cpp
Normal file
|
@ -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
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "tscript.h"
|
||||
|
||||
// FIX ME!! This code not yet functional.
|
||||
|
||||
#define TERMINATOR '~'
|
||||
#define SPACE_HOLDER '_'
|
||||
|
||||
// processScript by Bryan Montgomery
|
||||
// modified to handle script file by Paul Brannan
|
||||
BOOL TScript::processScript (char* data) {
|
||||
/* char* end = strchr(script,TERMINATOR);
|
||||
if (0 == end) {
|
||||
return true;
|
||||
} else {
|
||||
char* current = new char(sizeof(char)*strlen(script));
|
||||
strncpy(current,script,(int)(end-script));
|
||||
current[(int)(end-script)]=0;
|
||||
char *ptr=end;
|
||||
if (strstr(data,current) != 0) {
|
||||
script = ++end;
|
||||
end = strchr(script,TERMINATOR);
|
||||
while ((ptr = strchr(ptr,SPACE_HOLDER)) != 0 && ptr < end) {
|
||||
*ptr=' ';
|
||||
}
|
||||
Network.WriteString(script,(int)(end-script));
|
||||
Network.WriteString("\r\n",2);
|
||||
script = ++end;
|
||||
}
|
||||
delete current;
|
||||
}*/
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void TScript::initScript (char *filename) {
|
||||
if(fp) fclose(fp);
|
||||
fp = fopen(filename, "rt");
|
||||
}
|
20
rosapps/net/telnet/src/tscript.h
Normal file
20
rosapps/net/telnet/src/tscript.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef __TSCRIPT_H
|
||||
#define __TSCRIPT_H
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include "tnetwork.h"
|
||||
|
||||
class TScript {
|
||||
public:
|
||||
TScript(TNetwork &RefNetwork):Network(RefNetwork) {fp = NULL;}
|
||||
~TScript() {}
|
||||
BOOL processScript(char *data);
|
||||
void initScript(char *filename);
|
||||
private:
|
||||
FILE *fp;
|
||||
char *script;
|
||||
TNetwork &Network;
|
||||
};
|
||||
|
||||
#endif
|
369
rosapps/net/telnet/src/tscroll.cpp
Normal file
369
rosapps/net/telnet/src/tscroll.cpp
Normal file
|
@ -0,0 +1,369 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
//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: tscroll.cpp
|
||||
//
|
||||
// Contents: Telnet Handler
|
||||
//
|
||||
// Product: telnet
|
||||
//
|
||||
// Revisions: Dec. 5, 1998 Paul Brannan <pbranna@clemson.edu>
|
||||
// June 15, 1998 Paul Brannan
|
||||
//
|
||||
// This is code originally from tnclass.cpp and ansiprsr.cpp
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <windows.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include "tscroll.h"
|
||||
#include "tncon.h"
|
||||
#include "tconsole.h"
|
||||
#include "tnconfig.h"
|
||||
|
||||
enum {
|
||||
HEX,
|
||||
DUMP,
|
||||
DUMPB,
|
||||
TEXTB,
|
||||
};
|
||||
|
||||
int DummyStripBuffer(char *start, char *end, int width) {return 0;}
|
||||
|
||||
TScroller::TScroller(TMouse &M, int size) : Mouse(M) {
|
||||
iScrollSize = size;
|
||||
pcScrollData = new char[iScrollSize];
|
||||
iScrollEnd = 0;
|
||||
iPastEnd = 0;
|
||||
memset(pcScrollData, ' ', iScrollSize);
|
||||
|
||||
if(stricmp(ini.get_scroll_mode(), "hex") == 0) iDisplay = HEX;
|
||||
else if(stricmp(ini.get_scroll_mode(), "dump") == 0) iDisplay = DUMP;
|
||||
else if(stricmp(ini.get_scroll_mode(), "dumpb") == 0) iDisplay = DUMPB;
|
||||
else if(stricmp(ini.get_scroll_mode(), "text") == 0) iDisplay = TEXTB;
|
||||
else iDisplay = DUMP;
|
||||
|
||||
strip = &DummyStripBuffer;
|
||||
}
|
||||
|
||||
TScroller::~TScroller() {
|
||||
delete[] pcScrollData;
|
||||
}
|
||||
|
||||
void TScroller::init(stripfunc *s) {
|
||||
strip = s;
|
||||
}
|
||||
|
||||
// Fixed update of circular buffer (Paul Brannan 12/4/98)
|
||||
// Note: iScrollEnd is one character beyond the end
|
||||
void TScroller::update(const char *pszHead, const char *pszTail) {
|
||||
if ((iScrollEnd)+(pszTail-pszHead) < iScrollSize) {
|
||||
memcpy(&pcScrollData[iScrollEnd], pszHead, pszTail-pszHead);
|
||||
} else if (pszTail-pszHead > iScrollSize) {
|
||||
memcpy(pcScrollData, pszTail-iScrollSize, iScrollSize);
|
||||
iScrollEnd = 0;
|
||||
} else {
|
||||
memcpy(&pcScrollData[iScrollEnd], pszHead, iScrollSize-iScrollEnd);
|
||||
memcpy(&pcScrollData[0], pszHead + (iScrollSize-iScrollEnd),
|
||||
pszTail-pszHead-(iScrollSize-iScrollEnd));
|
||||
}
|
||||
|
||||
// This could probably be optimized better, but it's probably not worth it
|
||||
int temp = iScrollEnd;
|
||||
iScrollEnd = ((iScrollEnd)+(pszTail-pszHead))%iScrollSize;
|
||||
if(iScrollEnd < temp) iPastEnd = 1;
|
||||
}
|
||||
|
||||
// Perhaps this should be moved to Tconsole.cpp? (Paul Brannan 6/12/98)
|
||||
static BOOL WriteConsoleOutputCharAndAttribute(
|
||||
HANDLE hConsoleOutput, // handle of a console screen buffer
|
||||
CHAR * lpWriteBuffer,
|
||||
WORD wAttrib,
|
||||
SHORT sX,
|
||||
SHORT sY ){
|
||||
// we ought to allocate memory before writing to an address (PB 5/12/98)
|
||||
DWORD cWritten;
|
||||
const LPDWORD lpcWritten = &cWritten;
|
||||
|
||||
DWORD cWriteCells = strlen(lpWriteBuffer);
|
||||
COORD coordWrite = {sX,sY};
|
||||
LPWORD lpwAttribute = new WORD[cWriteCells];
|
||||
for (unsigned int i = 0; i < cWriteCells; i++)
|
||||
lpwAttribute[i] = wAttrib;
|
||||
WriteConsoleOutputAttribute(
|
||||
hConsoleOutput, // handle of a console screen buffer
|
||||
lpwAttribute, // address of buffer to write attributes from
|
||||
cWriteCells, // number of character cells to write to
|
||||
coordWrite, // coordinates of first cell to write to
|
||||
lpcWritten // address of number of cells written to
|
||||
);
|
||||
WriteConsoleOutputCharacter(
|
||||
hConsoleOutput, // handle of a console screen buffer
|
||||
lpWriteBuffer, // address of buffer to write characters from
|
||||
cWriteCells, // number of character cells to write to
|
||||
coordWrite, // coordinates of first cell to write to
|
||||
lpcWritten // address of number of cells written to
|
||||
);
|
||||
delete [] lpwAttribute;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void hexify(int x, char *str, int len) {
|
||||
for(int j = len - 1; j >= 0; j--) {
|
||||
str[j] = x % 16;
|
||||
if(str[j] > 9) str[j] += 'A' - 10;
|
||||
else str[j] += '0';
|
||||
x /= 16;
|
||||
}
|
||||
}
|
||||
|
||||
static int setmaxlines(int iDisplay, int iScrollSize, int strippedlines,
|
||||
int con_width) {
|
||||
switch(iDisplay) {
|
||||
case HEX: return(iScrollSize / 16); break;
|
||||
case DUMP:
|
||||
case DUMPB: return(iScrollSize / con_width); break;
|
||||
case TEXTB: return(strippedlines); break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void setstatusline(char *szStatusLine, int len, int iDisplay) {
|
||||
memset(szStatusLine, ' ', len);
|
||||
memcpy(&szStatusLine[1], "Scrollback Mode", 15);
|
||||
switch(iDisplay) {
|
||||
case HEX: memcpy(&szStatusLine[len / 2 - 1], "HEX", 3); break;
|
||||
case DUMP: memcpy(&szStatusLine[len / 2 - 2], "DUMP", 4); break;
|
||||
case DUMPB: memcpy(&szStatusLine[len / 2 - 5], "BINARY DUMP", 11); break;
|
||||
case TEXTB: memcpy(&szStatusLine[len / 2 - 2], "TEXT", 4); break;
|
||||
}
|
||||
memcpy(&szStatusLine[len - 6], "READY", 5);
|
||||
szStatusLine[len] = 0;
|
||||
}
|
||||
|
||||
void TScroller::ScrollBack(){
|
||||
char p;
|
||||
int r,c;
|
||||
|
||||
// define colors (Paul Brannan 7/5/98)
|
||||
int normal = (ini.get_scroll_bg() << 4) | ini.get_scroll_fg();
|
||||
// int inverse = (ini.get_scroll_fg() << 4) | ini.get_scroll_bg();
|
||||
int status = (ini.get_status_bg() << 4) | ini.get_status_fg();
|
||||
|
||||
CHAR_INFO* chiBuffer;
|
||||
chiBuffer = newBuffer();
|
||||
saveScreen(chiBuffer);
|
||||
|
||||
HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo;
|
||||
GetConsoleScreenBufferInfo(hStdout, &ConsoleInfo);
|
||||
|
||||
// Update iScrollBegin -- necessary in case the buffer isn't full yet
|
||||
long iScrollBegin, iScrollLast;
|
||||
if(iPastEnd == 0) {
|
||||
iScrollBegin = 0;
|
||||
iScrollLast = iScrollEnd - 1;
|
||||
} else {
|
||||
iScrollBegin = iScrollEnd;
|
||||
iScrollLast = iScrollSize - 1;
|
||||
}
|
||||
|
||||
// Create buffer with ANSI codes stripped
|
||||
// Fixed this to work properly with a circular buffer (PB 12/4/98)
|
||||
char *stripped = new char[iScrollSize];
|
||||
memcpy(stripped, pcScrollData + iScrollBegin, iScrollSize -
|
||||
iScrollBegin);
|
||||
if(iScrollBegin != 0) memcpy(stripped + (iScrollSize - iScrollBegin),
|
||||
pcScrollData, iScrollBegin - 1);
|
||||
int strippedlines = (*strip)(stripped, stripped + iScrollLast,
|
||||
CON_COLS);
|
||||
|
||||
// Calculate the last line of the scroll buffer (Paul Brannan 12/4/98)
|
||||
int maxlines = setmaxlines(iDisplay, iScrollLast + 1, strippedlines,
|
||||
CON_COLS);
|
||||
|
||||
// init scroll position
|
||||
int current = maxlines - CON_HEIGHT + 1;
|
||||
if(current < 0) current = 0;
|
||||
|
||||
// paint border and info
|
||||
// paint last two lines black on white
|
||||
char * szStatusLine;
|
||||
szStatusLine = new char[CON_WIDTH+2];
|
||||
setstatusline(szStatusLine, CON_COLS, iDisplay);
|
||||
WriteConsoleOutputCharAndAttribute(hStdout, szStatusLine, status,
|
||||
CON_LEFT, CON_BOTTOM);
|
||||
|
||||
// loop while not done
|
||||
BOOL done = FALSE;
|
||||
while (!done){
|
||||
switch (iDisplay){
|
||||
case HEX:
|
||||
memset(szStatusLine, ' ', CON_COLS);
|
||||
szStatusLine[8] = ':';
|
||||
szStatusLine[34] = '-';
|
||||
for (r = 0; r < CON_HEIGHT; r++) {
|
||||
hexify((r + current) * 16, &szStatusLine[2], 6);
|
||||
for (c = 0; c < 16; c++){
|
||||
if (c+(16*(r+current)) >= iScrollLast)
|
||||
p = 0;
|
||||
else
|
||||
p = pcScrollData[(c+16*(r+current) + iScrollBegin) %
|
||||
iScrollSize];
|
||||
hexify((char)p, &szStatusLine[11 + 3*c], 2);
|
||||
if (!iscntrl(p)) {
|
||||
szStatusLine[60 + c] = (char)p;
|
||||
} else {
|
||||
szStatusLine[60 + c] = '.';
|
||||
}
|
||||
}
|
||||
for(int j = 0; j < 16; j++) {
|
||||
}
|
||||
szStatusLine[CON_COLS] = '\0';
|
||||
WriteConsoleOutputCharAndAttribute(hStdout, szStatusLine,
|
||||
normal, CON_LEFT, r+CON_TOP);
|
||||
}
|
||||
break;
|
||||
case DUMP:
|
||||
for (r = 0; r < CON_HEIGHT; r++) {
|
||||
for (c = 0; c <= CON_WIDTH; c++) {
|
||||
if (c+((CON_COLS)*(r+current)) >= iScrollLast) p = ' ';
|
||||
else p = pcScrollData[(c+((CON_COLS)*(r+current))
|
||||
+ iScrollBegin) % iScrollSize];
|
||||
if (!iscntrl(p))
|
||||
szStatusLine[c] = p;
|
||||
else
|
||||
szStatusLine[c] = '.';
|
||||
}
|
||||
szStatusLine[c] = '\0';
|
||||
WriteConsoleOutputCharAndAttribute(hStdout, szStatusLine,
|
||||
normal, CON_LEFT, r+CON_TOP);
|
||||
}
|
||||
break;
|
||||
case DUMPB:
|
||||
for (r = 0; r < CON_HEIGHT; r++) {
|
||||
for (c = 0; c <= CON_WIDTH; c++) {
|
||||
if (c+((CON_COLS)*(r+current)) >= iScrollLast) p = ' ';
|
||||
else p = pcScrollData[ (c+((CON_COLS)*(r+current))
|
||||
+ iScrollBegin) % iScrollSize];
|
||||
if (p != 0)
|
||||
szStatusLine[c] = p;
|
||||
else
|
||||
szStatusLine[c] = ' ';
|
||||
}
|
||||
szStatusLine[c] = '\0';
|
||||
WriteConsoleOutputCharAndAttribute(hStdout, szStatusLine,
|
||||
normal, CON_LEFT, r+CON_TOP);
|
||||
}
|
||||
break;
|
||||
case TEXTB: {
|
||||
int ch, lines, x;
|
||||
// Find the starting position
|
||||
for(ch = 0, lines = 0, x = 1; ch < iScrollSize &&
|
||||
lines < current; ch++, x++) {
|
||||
|
||||
if(stripped[ch] == '\n') lines++;
|
||||
if(stripped[ch] == '\r') x = 1;
|
||||
}
|
||||
|
||||
for (r = 0; r < CON_HEIGHT; r++) {
|
||||
memset(szStatusLine, ' ', CON_COLS);
|
||||
for(c = 0; c <= CON_WIDTH; c++) {
|
||||
int done = FALSE;
|
||||
if (ch >= iScrollSize) p = ' ';
|
||||
else p = stripped[ch];
|
||||
switch(p) {
|
||||
case 10: done = TRUE; break;
|
||||
case 13: c = 0; break;
|
||||
default: szStatusLine[c] = p;
|
||||
}
|
||||
ch++;
|
||||
if(done) break;
|
||||
}
|
||||
szStatusLine[CON_COLS] = '\0';
|
||||
WriteConsoleOutputCharAndAttribute(hStdout, szStatusLine,
|
||||
normal, CON_LEFT, r+CON_TOP);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
setstatusline(szStatusLine, CON_COLS, iDisplay);
|
||||
WriteConsoleOutputCharAndAttribute(hStdout, szStatusLine, status,
|
||||
CON_LEFT, CON_BOTTOM);
|
||||
|
||||
// paint scroll back data
|
||||
// get key input
|
||||
switch(scrollkeys()){
|
||||
case VK_ESCAPE:
|
||||
done = TRUE;
|
||||
break;
|
||||
case VK_PRIOR:
|
||||
if ( current > CON_HEIGHT)
|
||||
current-= CON_HEIGHT;
|
||||
else
|
||||
current = 0;
|
||||
break;
|
||||
case VK_NEXT:
|
||||
if ( current < maxlines - 2*CON_HEIGHT + 2)
|
||||
current += CON_HEIGHT;
|
||||
else
|
||||
current = maxlines - CON_HEIGHT + 1;
|
||||
break;
|
||||
case VK_DOWN:
|
||||
if (current <= maxlines - CON_HEIGHT) current++;
|
||||
break;
|
||||
case VK_UP:
|
||||
if ( current > 0) current--;
|
||||
break;
|
||||
case VK_TAB:
|
||||
iDisplay = (iDisplay+1)%4;
|
||||
maxlines = setmaxlines(iDisplay, iScrollLast + 1, strippedlines,
|
||||
CON_COLS);
|
||||
if(current > maxlines) current = maxlines - 1;
|
||||
if(current < 0) current = 0;
|
||||
break;
|
||||
case VK_END:
|
||||
current = maxlines - CON_HEIGHT + 1;
|
||||
if(current < 0) current = 0;
|
||||
break;
|
||||
case VK_HOME:
|
||||
current = 0;
|
||||
break;
|
||||
case SC_MOUSE:
|
||||
Mouse.scrollMouse();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Clean up
|
||||
restoreScreen(chiBuffer);
|
||||
delete[] szStatusLine;
|
||||
delete[] chiBuffer;
|
||||
delete[] stripped;
|
||||
}
|
26
rosapps/net/telnet/src/tscroll.h
Normal file
26
rosapps/net/telnet/src/tscroll.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
#ifndef __TSCROLL_H
|
||||
#define __TSCROLL_H
|
||||
|
||||
#include "tconsole.h"
|
||||
#include "tmouse.h"
|
||||
|
||||
typedef int(stripfunc)(char *, char *, int);
|
||||
|
||||
class TScroller {
|
||||
private:
|
||||
char *pcScrollData;
|
||||
long iScrollSize;
|
||||
long iScrollEnd;
|
||||
int iPastEnd;
|
||||
int iDisplay;
|
||||
stripfunc *strip;
|
||||
TMouse &Mouse;
|
||||
public:
|
||||
void init(stripfunc *s);
|
||||
void update(const char *pszBegin, const char *pszEnd);
|
||||
void ScrollBack();
|
||||
TScroller(TMouse &M, int size=20000);
|
||||
~TScroller();
|
||||
};
|
||||
|
||||
#endif
|
548
rosapps/net/telnet/src/ttelhndl.cpp
Normal file
548
rosapps/net/telnet/src/ttelhndl.cpp
Normal file
|
@ -0,0 +1,548 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
//Telnet Win32 : an ANSI telnet client.
|
||||
//Copyright (C) 1998 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: ttelhndl.cpp
|
||||
//
|
||||
// Contents: Telnet Handler
|
||||
//
|
||||
// Product: telnet
|
||||
//
|
||||
// Revisions: August 30, 1998 Paul Brannan <pbranna@clemson.edu>
|
||||
// June 15, 1998 pbranna@clemson.edu (Paul Brannan)
|
||||
//
|
||||
// This is code originally from tnnet.cpp and ansiprsr.cpp
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <string.h>
|
||||
#include "ttelhndl.h"
|
||||
#include "telnet.h"
|
||||
#include "tnconfig.h"
|
||||
#include "tparams.h"
|
||||
|
||||
int naws_string(char *buf, int width, int height);
|
||||
|
||||
// This helps make the code more readable (Paul Brannan 1/1/99)
|
||||
#ifdef DEBUG_TELOPT
|
||||
#define TELOPT_PRINTD(x) printit(x);
|
||||
#define TELOPT_PRINTD2(x,n) { \
|
||||
static char buf[20]; \
|
||||
printit(s); \
|
||||
printit(" "); \
|
||||
itoa(d, buf, 10); \
|
||||
printit(buf); \
|
||||
printit("\n"); \
|
||||
}
|
||||
#else
|
||||
#define TELOPT_PRINTD(x) ;
|
||||
#define TELOPT_PRINTD2(x,n) ;
|
||||
#endif
|
||||
|
||||
// A new print function for debugging (Paul Brannan 5/15/98)
|
||||
#ifdef DEBUG_TELOPT
|
||||
void TTelnetHandler::print_telopt(const char *s, int d) {
|
||||
static char buf[20];
|
||||
printit(s);
|
||||
printit(" ");
|
||||
itoa(d, buf, 10);
|
||||
printit(buf);
|
||||
printit("\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
TTelnetHandler::TTelnetHandler(TNetwork &RefNetwork, TConsole &RefConsole,
|
||||
TParser &RefParser):
|
||||
Network(RefNetwork), Console(RefConsole), Parser(RefParser) {
|
||||
init();
|
||||
|
||||
// Paul Brannan 9/13/98
|
||||
dwBuffer = ini.get_buffer_size();
|
||||
szBuffer = new char [dwBuffer];
|
||||
Network.SetNawsFunc(NULL);
|
||||
}
|
||||
|
||||
void TTelnetHandler::init() {
|
||||
iTermSet = 0;
|
||||
bInBinaryRx = 0;
|
||||
bInBinaryTx = 0;
|
||||
bInEchoTx = 0;
|
||||
bInEchoRx = 0;
|
||||
Network.set_local_echo(1);
|
||||
}
|
||||
|
||||
TTelnetHandler::~TTelnetHandler() {
|
||||
delete[] szBuffer;
|
||||
}
|
||||
|
||||
int TTelnetHandler::escapeIAC(char *buf, int length){
|
||||
// The size of buffer must be greater than 2 * length to ensure no memory
|
||||
// out of bounds errors. The 0xff is escaped into 0xff 0xff.
|
||||
char * temp;
|
||||
temp = new char [length * 2];
|
||||
int current=0;
|
||||
for (int x=0; x < length; x++){
|
||||
if (buf[x] == (signed char)IAC)
|
||||
temp[current++]=(char)IAC;
|
||||
temp[current++]=buf[x];
|
||||
}
|
||||
memcpy( buf, temp, current);
|
||||
delete [] temp;
|
||||
return current;
|
||||
}
|
||||
|
||||
// This lets us get rid of all the printf's (Paul Brannan 5/15/98)
|
||||
void TTelnetHandler::SendIAC(char c) {
|
||||
static char buf[2] = {IAC};
|
||||
buf[1] = c;
|
||||
Network.WriteString(buf, 2);
|
||||
}
|
||||
void TTelnetHandler::SendIAC(char c1, char c2) {
|
||||
static char buf[3] = {IAC};
|
||||
buf[1] = c1; buf[2] = c2;
|
||||
Network.WriteString(buf, 3);
|
||||
}
|
||||
void TTelnetHandler::SendIACParams(char c) {
|
||||
static char buf[2];
|
||||
buf[0] = c;
|
||||
static int length = escapeIAC(buf, 1);
|
||||
Network.WriteString(buf, length);
|
||||
}
|
||||
void TTelnetHandler::SendIACParams(char c1, char c2) {
|
||||
static char buf[4];
|
||||
buf[0] = c1; buf[1] = c2;
|
||||
static int length = escapeIAC(buf, 2);
|
||||
Network.WriteString(buf, length);
|
||||
}
|
||||
|
||||
int naws_string(char *b, int width, int height) {
|
||||
int l = 0;
|
||||
unsigned char *buf = (unsigned char *)b;
|
||||
|
||||
union {
|
||||
char szResponse[2];
|
||||
int n;
|
||||
};
|
||||
|
||||
buf[l++] = IAC;
|
||||
buf[l++] = SB;
|
||||
buf[l++] = TELOPT_NAWS;
|
||||
|
||||
n = width;
|
||||
buf[l] = szResponse[1];
|
||||
if(buf[l-1] == IAC) buf[l++] = IAC;
|
||||
buf[l++] = szResponse[0];
|
||||
if(buf[l-1] == IAC) buf[l++] = IAC;
|
||||
|
||||
n = height;
|
||||
buf[l++] = szResponse[1];
|
||||
if(buf[l-1] == IAC) buf[l++] = IAC;
|
||||
buf[l++] = szResponse[0];
|
||||
if(buf[l-1] == IAC) buf[l++] = IAC;
|
||||
|
||||
buf[l++] = IAC;
|
||||
buf[l++] = SE;
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
// Ioannou 29 May 1998 : Something strange happens with
|
||||
// Borland compiler at this point when it passes the arguments
|
||||
// to SendIACParams. It always sends 80 lines to the server !!!
|
||||
// There seems to be a bug with optimization (the disassemble shows
|
||||
// that it uses an address plus 0xa than the right one).
|
||||
// This turns them off for this point.
|
||||
#ifdef __BORLANDC__
|
||||
#pragma -O-
|
||||
#endif
|
||||
|
||||
// Removed old printf code that was commented out to clean this function
|
||||
// up a bit (Paul brannan 6/15/98)
|
||||
char* TTelnetHandler::ParseIAC(char* pszBuffer, char* pszBufferEnd)
|
||||
{
|
||||
// int n,l;
|
||||
// char szResponse[40];
|
||||
// Ioannou 29 May 1998 : I prefer the union redefinitions
|
||||
// than the typecasting (used with them from Pascal and Cobol :-) )
|
||||
// FIX ME !!!! Shall we use the winsock routines instead ?
|
||||
|
||||
union {
|
||||
char szResponse[2];
|
||||
int n;
|
||||
};
|
||||
|
||||
// Added support for user-defined term name (Paul Brannan 5/13/98)
|
||||
#define LASTTERM 4
|
||||
const char *pszTerms[] = {ini.get_term(), "ANSI","DEC-VT100","DEC-VT52","UNKNOWN"};
|
||||
if(!iTermSet && (pszTerms[0] == 0 || *pszTerms[0] == 0)) iTermSet++;
|
||||
|
||||
if (pszBuffer + 2 < pszBufferEnd) {
|
||||
switch ((unsigned char)pszBuffer[1]) {
|
||||
|
||||
///////////////// DO ////////////////////
|
||||
case DO:
|
||||
{
|
||||
switch (pszBuffer[2]){
|
||||
case TELOPT_BINARY:
|
||||
TELOPT_PRINTD("RCVD DO TELOPT_BINARY\n");
|
||||
if (!bInBinaryRx){
|
||||
SendIAC(WILL, TELOPT_BINARY);
|
||||
bInBinaryRx = 1;
|
||||
TELOPT_PRINTD("SENT WILL TELOPT_BINARY\n");
|
||||
}
|
||||
break;
|
||||
case TELOPT_ECHO:
|
||||
// we shouldn't echo for the server! (Paul Brannan 5/30/98)
|
||||
TELOPT_PRINTD2("RCVD DO TELOPT_ECHO", pszBuffer[2]);
|
||||
SendIAC(WONT, TELOPT_ECHO);
|
||||
TELOPT_PRINTD("SENT WONT TELOPT_ECHO\n");
|
||||
break;
|
||||
case TELOPT_TTYPE:
|
||||
TELOPT_PRINTD("RCVD DO TELOPT_TTYPE\n");
|
||||
SendIAC(WILL, TELOPT_TTYPE);
|
||||
TELOPT_PRINTD("SENT WILL TELOPT_TTYPE\n");
|
||||
break;
|
||||
case TELOPT_NAWS:
|
||||
TELOPT_PRINTD("RCVD DO TELOPT_NAWS\n");
|
||||
SendIAC(WILL, TELOPT_NAWS);
|
||||
SendIAC(SB, TELOPT_NAWS);
|
||||
|
||||
Network.SetNawsFunc(naws_string);
|
||||
|
||||
n = Console.GetWidth();
|
||||
SendIACParams(szResponse[1],szResponse [0]);
|
||||
|
||||
n = Console.GetHeight();
|
||||
SendIACParams(szResponse[1],szResponse[0]);
|
||||
|
||||
SendIAC(SE);
|
||||
TELOPT_PRINTD("SENT WILL TELOPT_NAWS\n");
|
||||
break;
|
||||
case TELOPT_XDISPLOC:
|
||||
TELOPT_PRINTD("RCVD DO TELOPT_XDISPLOC\n");
|
||||
SendIAC(WILL, TELOPT_XDISPLOC);
|
||||
TELOPT_PRINTD("SENT WILL TELOPT_XDISPLOC\n");
|
||||
printit("Retrieving IP...");
|
||||
break;
|
||||
default:
|
||||
TELOPT_PRINTD2("RCVD DO", pszBuffer[2]);
|
||||
SendIAC(WONT, pszBuffer[2]);
|
||||
TELOPT_PRINTD2("SENT WONT", pszBuffer[2]);
|
||||
break;
|
||||
}
|
||||
if (pszBuffer + 2 < pszBufferEnd)
|
||||
pszBuffer += 3;
|
||||
break;
|
||||
}
|
||||
|
||||
///////////////// WILL ////////////////////
|
||||
case WILL:
|
||||
{
|
||||
switch ((unsigned char)pszBuffer[2]){
|
||||
case TELOPT_BINARY:
|
||||
TELOPT_PRINTD("RCVD WILL TELOPT_BINARY\n");
|
||||
if (!bInBinaryTx){
|
||||
SendIAC(DO, TELOPT_BINARY);
|
||||
bInBinaryTx = 1;
|
||||
TELOPT_PRINTD("SENT DO TELOPT_BINARY\n");
|
||||
}
|
||||
break;
|
||||
case TELOPT_ECHO:
|
||||
TELOPT_PRINTD2("RCVD WILL TELOPT_ECHO", pszBuffer[2]);
|
||||
if(!bInEchoRx) {
|
||||
SendIAC(DO, TELOPT_ECHO);
|
||||
bInEchoRx = 1;
|
||||
Network.set_local_echo(0); // Paul Brannan 8/25/98
|
||||
if(iWillSGA) Network.set_line_mode(0);
|
||||
TELOPT_PRINTD2("SENT DO TELOPT_ECHO", pszBuffer[2]);
|
||||
if(Network.get_local_echo()) Network.set_line_mode(0);
|
||||
}
|
||||
break;
|
||||
|
||||
// Suppress Go Ahead (Paul Brannan 12/31/98)
|
||||
case TELOPT_SGA:
|
||||
TELOPT_PRINTD("RCVD WILL TELOPT_SGA\n");
|
||||
if(!iWillSGA) {
|
||||
SendIAC(DO, TELOPT_SGA);
|
||||
if(bInEchoRx) Network.set_line_mode(0);
|
||||
iWillSGA = 1;
|
||||
TELOPT_PRINTD("SENT DO TELOPT_SGA\n");
|
||||
}
|
||||
break;
|
||||
|
||||
////added 1/28/97
|
||||
default:
|
||||
TELOPT_PRINTD2("RCVD WILL", pszBuffer[2]);
|
||||
SendIAC(DONT, pszBuffer[2]);
|
||||
TELOPT_PRINTD2("SENT DONT", pszBuffer[2]);
|
||||
break;
|
||||
////
|
||||
}
|
||||
if (pszBuffer + 2 < pszBufferEnd)
|
||||
pszBuffer += 3;
|
||||
break;
|
||||
}
|
||||
|
||||
///////////////// WONT ////////////////////
|
||||
case WONT:
|
||||
{
|
||||
switch ((unsigned char)pszBuffer[2]){
|
||||
case TELOPT_ECHO:
|
||||
TELOPT_PRINTD("RCVD WONT TELOPT_ECHO\n");
|
||||
if (bInEchoRx){
|
||||
SendIAC(DONT, TELOPT_ECHO);
|
||||
// bInBinaryRx = 0;
|
||||
bInEchoRx = 0; // Paul Brannan 8/25/98
|
||||
Network.set_local_echo(1);
|
||||
Network.set_line_mode(0);
|
||||
TELOPT_PRINTD("SENT DONT TELOPT_ECHO\n");
|
||||
}
|
||||
break;
|
||||
|
||||
// Suppress Go Ahead (Paul Brannan 12/31/98)
|
||||
case TELOPT_SGA:
|
||||
TELOPT_PRINTD("RCVD WONT TELOPT_SGA\n");
|
||||
if(iWillSGA) {
|
||||
SendIAC(DONT, TELOPT_SGA);
|
||||
Network.set_line_mode(0);
|
||||
iWillSGA = 0;
|
||||
TELOPT_PRINTD("SENT DONT TELOPT_SGA\n");
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
TELOPT_PRINTD2("RCVD WONT", pszBuffer[2]);
|
||||
break;
|
||||
}
|
||||
if (pszBuffer + 2 < pszBufferEnd)
|
||||
pszBuffer += 3;
|
||||
break;
|
||||
}
|
||||
|
||||
///////////////// DONT ////////////////////
|
||||
case DONT:
|
||||
{
|
||||
switch ((unsigned char)pszBuffer[2]){
|
||||
case TELOPT_ECHO:
|
||||
TELOPT_PRINTD("RCVD DONT TELOPT_ECHO\n");
|
||||
if (bInEchoTx){
|
||||
SendIAC(WONT, TELOPT_ECHO);
|
||||
bInEchoTx = 0;
|
||||
TELOPT_PRINTD("SENT WONT TELOPT_ECHO\n");
|
||||
}
|
||||
break;
|
||||
case TELOPT_NAWS:
|
||||
TELOPT_PRINTD("RCVD DONT TELOPT_NAWS\n");
|
||||
SendIAC(WONT, TELOPT_NAWS);
|
||||
Network.SetNawsFunc(naws_string);
|
||||
TELOPT_PRINTD("SENT WONT TELOPT_NAWS\n");
|
||||
break;
|
||||
default:
|
||||
TELOPT_PRINTD2("RCVD DONT", pszBuffer[2]);
|
||||
break;
|
||||
}
|
||||
if (pszBuffer + 2 < pszBufferEnd)
|
||||
pszBuffer += 3;
|
||||
break;
|
||||
}
|
||||
|
||||
///////////////// SB ////////////////////
|
||||
case SB:
|
||||
{
|
||||
switch ((unsigned char)pszBuffer[2]){
|
||||
case TELOPT_TTYPE:
|
||||
if (pszBuffer + 5 < pszBufferEnd) {
|
||||
TELOPT_PRINTD("RCVD SB TELOPT_TTYPE\n");
|
||||
if (pszBuffer[3] == 1){
|
||||
TELOPT_PRINTD("SENT SB TT");
|
||||
TELOPT_PRINTD(pszTerms[iTermSet]);
|
||||
TELOPT_PRINTD("\n");
|
||||
SendIAC(SB, TELOPT_TTYPE);
|
||||
SendIACParams(0);
|
||||
Network.WriteString(pszTerms[iTermSet], strlen(pszTerms[iTermSet]));
|
||||
SendIAC(SE);
|
||||
|
||||
if (iTermSet < LASTTERM )
|
||||
iTermSet+=1;
|
||||
}
|
||||
if (pszBuffer + 5 < pszBufferEnd)
|
||||
pszBuffer += 6;
|
||||
}
|
||||
break;
|
||||
case TELOPT_XDISPLOC:
|
||||
if(pszBuffer + 5 < pszBufferEnd) {
|
||||
TELOPT_PRINTD("RCVD SB XDISPLOC\n");
|
||||
SendIAC(SB, TELOPT_XDISPLOC);
|
||||
TELOPT_PRINTD("SENT SB XDISPLOC");
|
||||
SendIACParams(0);
|
||||
if(Network.GetLocalAddress()) Network.WriteString(Network.GetLocalAddress(),
|
||||
strlen(Network.GetLocalAddress()));
|
||||
TELOPT_PRINTD(Network.GetLocalAddress());
|
||||
TELOPT_PRINTD("\n");
|
||||
SendIAC(SE);
|
||||
if (pszBuffer + 5 < pszBufferEnd)
|
||||
pszBuffer += 6;
|
||||
}
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
pszBuffer += 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return pszBuffer;
|
||||
}
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
// bring bug optimazations
|
||||
#pragma -O.
|
||||
#endif
|
||||
|
||||
// This is the code from TANSIParser::ParseBuffer. It parses out IACs, and
|
||||
// then calls TParser::ParseBuffer to do the terminal emulation.
|
||||
// (Paul Brannan 6/15/98)
|
||||
// Hopefully eliminating the unnecessary copying should speed things up a
|
||||
// little. (Paul Brannan 6/28/98)
|
||||
char* TTelnetHandler::ParseBuffer(char* pszBuffer, char* pszBufferEnd){
|
||||
char *pszResult;
|
||||
char *pszHead = pszBuffer;
|
||||
|
||||
if(Network.get_net_type() == TN_NETSOCKET) {
|
||||
while (pszBuffer < pszBufferEnd) {
|
||||
// if IAC then parse IAC
|
||||
if((unsigned char) *pszBuffer == IAC) {
|
||||
|
||||
// check for escaped IAC
|
||||
if((pszBufferEnd >= pszBuffer + 1) &&
|
||||
(unsigned char)*(pszBuffer + 1) == IAC) {
|
||||
// we move data at the front of the buffer to the end so
|
||||
// that if we only have IACs we won't return pszBuffer
|
||||
// even though we did parse something. Returning
|
||||
// pszBuffer is an error condition.
|
||||
memmove(pszHead + 1, pszHead, pszBuffer - pszHead);
|
||||
pszBuffer+=2;
|
||||
pszHead++;
|
||||
}
|
||||
// parse the IAC
|
||||
else {
|
||||
pszResult = ParseIAC(pszBuffer, pszBufferEnd);
|
||||
if(pszBuffer == pszResult) return pszBuffer;
|
||||
// see above regarding moving from front to end.
|
||||
memmove(pszHead + (pszResult - pszBuffer), pszHead,
|
||||
pszBuffer - pszHead);
|
||||
pszHead += (pszResult - pszBuffer);
|
||||
pszBuffer = pszResult;
|
||||
}
|
||||
}
|
||||
// else copy char over to ANSI buffer
|
||||
else {
|
||||
pszBuffer++;
|
||||
}
|
||||
}
|
||||
|
||||
// Not a socket connection, so don't parse out IACs.
|
||||
// (Paul Brannan 3/19/99)
|
||||
} else {
|
||||
pszBuffer = pszBufferEnd;
|
||||
}
|
||||
|
||||
return(Parser.ParseBuffer(pszHead, pszBuffer));
|
||||
}
|
||||
|
||||
// telProcessNetwork calls the member function TTelnetHandler::Go, since
|
||||
// TTelnetHandler::Go is not a static function, and cannot be called with
|
||||
// CreateThread(). (Paul Brannan 6/15/98)
|
||||
DWORD telProcessNetwork(LPVOID pvParams) {
|
||||
TelThreadParams *pParams = (TelThreadParams *)pvParams;
|
||||
return pParams->TelHandler.Go(&pParams->p);
|
||||
}
|
||||
|
||||
// This function is what used to be telProcessNetwork (Paul Brannan 6/15/98)
|
||||
DWORD TTelnetHandler::Go(LPVOID pvParams)
|
||||
{
|
||||
NetParams *pParams = (NetParams *)pvParams;
|
||||
|
||||
// No longer a need to copy pParams-> socket and create an instance
|
||||
// of TANSIParser (Paul Brannan 6/15/98)
|
||||
|
||||
Console.sync(); // Sync with the parser so the cursor is positioned
|
||||
|
||||
Parser.Init(); // Reset the parser (Paul Brannan 9/19/98)
|
||||
init(); // Turn on local echo (Paul Brannan 9/19/98)
|
||||
|
||||
*pParams->bNetFinished = 0;
|
||||
char* pszHead = szBuffer;
|
||||
char* pszTail = szBuffer;
|
||||
while (!*pParams->bNetFinish) {
|
||||
// Get data from Socket
|
||||
*pParams->bNetPaused = 1; //Pause
|
||||
int Result = Network.ReadString(pszTail, (szBuffer + dwBuffer) - pszTail);
|
||||
|
||||
// Speed up mouse by not going into loop (Paul Brannan 8/10/98)
|
||||
// while(*pParams->bNetPause && !*pParams->bNetFinish) *pParams->bNetPaused = 1; //Pause
|
||||
if(WaitForSingleObject(pParams->hPause, 0) == WAIT_OBJECT_0)
|
||||
WaitForSingleObject(pParams->hUnPause, INFINITE);
|
||||
|
||||
*pParams->bNetPaused = 0; //UnPause
|
||||
|
||||
if (Result <= 0 || Result > dwBuffer ){
|
||||
break;
|
||||
}
|
||||
pszTail += Result;
|
||||
|
||||
// Process the buffer
|
||||
char* pszNewHead = pszHead;
|
||||
do {
|
||||
// Speed up mouse by not going into loop (Paul Brannan 8/10/98)
|
||||
if(WaitForSingleObject(pParams->hPause, 0) == WAIT_OBJECT_0) {
|
||||
*pParams->bNetPaused = 1;
|
||||
WaitForSingleObject(pParams->hUnPause, INFINITE);
|
||||
*pParams->bNetPaused = 0;
|
||||
}
|
||||
|
||||
pszHead = pszNewHead;
|
||||
pszNewHead = ParseBuffer(pszHead, pszTail); // Parse buffer
|
||||
} while ((pszNewHead != pszHead) && (pszNewHead < pszTail) && !*pParams->bNetFinish);
|
||||
pszHead = pszNewHead;
|
||||
|
||||
// When we reach the end of the buffer, move contents to the
|
||||
// beginning of the buffer to get free space at the end.
|
||||
if (pszTail == (szBuffer + dwBuffer)) {
|
||||
memmove(szBuffer, pszHead, pszTail - pszHead);
|
||||
pszTail = szBuffer + (pszTail - pszHead);
|
||||
pszHead = szBuffer;
|
||||
}
|
||||
}
|
||||
SetEvent(pParams->hExit);
|
||||
|
||||
printm(0, FALSE, MSG_TERMBYREM);
|
||||
*pParams->bNetPaused = 1; //Pause
|
||||
*pParams->bNetFinished = 1;
|
||||
return 0;
|
||||
}
|
51
rosapps/net/telnet/src/ttelhndl.h
Normal file
51
rosapps/net/telnet/src/ttelhndl.h
Normal file
|
@ -0,0 +1,51 @@
|
|||
#ifndef __TTELHNDL_H
|
||||
#define __TTELHNDL_H
|
||||
|
||||
#include "tparser.h"
|
||||
#include "tnetwork.h"
|
||||
|
||||
DWORD telProcessNetwork(LPVOID pvParams);
|
||||
|
||||
class TTelnetHandler {
|
||||
private:
|
||||
int iTermSet;
|
||||
int bInBinaryRx, bInBinaryTx;
|
||||
int bInEchoTx, bInEchoRx;
|
||||
int iWillSGA;
|
||||
|
||||
void init();
|
||||
|
||||
int escapeIAC(char *buf, int length);
|
||||
|
||||
// Paul Brannan 5/15/98
|
||||
void SendIAC(char c);
|
||||
void SendIAC(char c1, char c2);
|
||||
void SendIACParams(char c);
|
||||
void SendIACParams(char c1, char c2);
|
||||
void print_telopt(const char *s, int d);
|
||||
|
||||
TNetwork &Network;
|
||||
TConsole &Console;
|
||||
TParser &Parser;
|
||||
|
||||
char* ParseBuffer(char* pszBuffer, char* pszBufferEnd);
|
||||
char* ParseIAC(char* pszBuffer, char* pszBufferEnd);
|
||||
|
||||
// Paul Brannan 9/13/98
|
||||
char *szBuffer, *tmpBuffer;
|
||||
char *ansiBufferStart, *ansiBufferEnd;
|
||||
int dwBuffer;
|
||||
|
||||
void do_naws(int width, int height);
|
||||
|
||||
public:
|
||||
TTelnetHandler(TNetwork &RefNetwork, TConsole &RefConsole,
|
||||
TParser &RefParser);
|
||||
~TTelnetHandler();
|
||||
|
||||
DWORD Go(LPVOID pvParams);
|
||||
|
||||
int get_term() {return iTermSet;}
|
||||
};
|
||||
|
||||
#endif
|
2616
rosapps/net/telnet/telnet.cfg
Normal file
2616
rosapps/net/telnet/telnet.cfg
Normal file
File diff suppressed because it is too large
Load diff
BIN
rosapps/net/telnet/telnet.ico
Normal file
BIN
rosapps/net/telnet/telnet.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.6 KiB |
53
rosapps/net/telnet/telnet.ini
Normal file
53
rosapps/net/telnet/telnet.ini
Normal file
|
@ -0,0 +1,53 @@
|
|||
[Terminal]
|
||||
;Dumpfile=
|
||||
;Term=ansi
|
||||
;Telnet_Redir=0
|
||||
;Input_Redir=0
|
||||
;Output_Redir=0
|
||||
;Strip_Redir=FALSE
|
||||
;Destructive_Backspace=FALSE
|
||||
;Speaker_Beep=TRUE
|
||||
;Beep=TRUE
|
||||
;EightBit_Ansi=True
|
||||
;VT100_Mode=True
|
||||
;Disable_Break=FALSE
|
||||
;Preserve_Colors=FALSE
|
||||
;Wrap_Line=TRUE
|
||||
;Fast_Write=TRUE
|
||||
;Term_Width=-1
|
||||
;Term_Height=-1
|
||||
;Wide_Enable=FALSE
|
||||
;Buffer_Size=2048
|
||||
|
||||
[Colors]
|
||||
;Blink_bg=-1
|
||||
;Blink_fg=2
|
||||
;Underline_bg=-1
|
||||
;Underline_fg=3
|
||||
;UlBlink_bg=-1
|
||||
;UlBlink_fg=1
|
||||
;Normal_bg=0
|
||||
;Normal_fg=7
|
||||
;Scroll_bg=0
|
||||
;Scroll_fg=7
|
||||
;Status_bg=1
|
||||
;Status_fg=15
|
||||
|
||||
[Mouse]
|
||||
;Enable_Mouse=1
|
||||
|
||||
[Printer]
|
||||
;Printer_Name=LPT1
|
||||
|
||||
[Keyboard]
|
||||
;Escape_key=]
|
||||
;Scrollback_key=[
|
||||
;Dial_key=\
|
||||
;Alt_erase=FALSE
|
||||
;Keyboard_paste=FALSE
|
||||
;Keyfile=keys.cfg
|
||||
;Default_Config=vt100
|
||||
|
||||
[Scrollback]
|
||||
;Scroll_Mode=DUMP
|
||||
;Scroll_Enable=TRUE
|
Loading…
Reference in a new issue