57 added + 9 removed + 3 modified, total 69 files
reactos/apps/utils/net/telnet
diff -N Makefile.mingw
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Makefile.mingw 21 Nov 2004 22:24:55 -0000 1.1
@@ -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
reactos/apps/utils/net/telnet
diff -N telnet.cfg
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ telnet.cfg 21 Nov 2004 22:24:55 -0000 1.1
@@ -0,0 +1,2616 @@
+; Console Telnet 2.0 keys.cfg
+;
+[comment]
+
+This is a completely rewritten configuration file for Console Telnet 2.0.
+
+Now you can define multiple keymaps, character maps, and combine them in your
+own ways.
+
+Possible definition:
+ [COMMENT]
+ ...
+ [END COMMENT]
+ This is for commenting a big part of text. can be nested.
+ In text these also work:
+ ; - First printable character in line, which is completely
+ ignored.
+ // - Like C++ comment
+
+ [GLOBAL]
+ ...
+ [END GLOBAL]
+ This part is required. For an explanation look at the body.
+
+ [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 definitions:
+
+ <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
+ NUMLOCK
+ CAPSLOCK
+ SCROLLLOCK
+ APP_KEY
+ APP2_KEY
+ APP3_KEY
+ APP4_KEY
+
+ Undefined enhanced keys will use the non-enhanced definition.
+
+ APP_KEY, APP2_KEY, and APP3_KEY are application-specific key modes.
+ Other terminal emulations (which have not yet been implemented) may
+ use other definitions for these keys, but for the standard ANSI
+ emulation, these mean:
+ APP_KEY - VT100 application cursor keys
+ APP2_KEY - VT52 cursor keys
+ APP3_KEY - VT102 alternate keypad mode
+ APP4_KEY - VT100 newline mode set
+
+ 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.
+ Rather, if you put \000 you undefine a key. If you must send a NULL character,
+ please use \TN_NULL\.
+
+ A word on special sequences:
+ Any sequence of the form: \TN_...\ is a special sequence, which will perform a
+ special function for telnet. You may substitute one of these for keytranslation
+ for any key. Some of the special sequences that telnet recognizes:
+
+ \TN_ESCAPE Escape into the telnet client
+ \TN_SCROLLBACK Go into the scrollback buffer
+ \TN_DIAL Start a new telnet session
+ \TN_PASTE Paste the contents of the clipboard to the server
+ \TN_NULL Send a null sequence to the server
+ \TN_CR Send \rNULL to the server
+ \TN_CRLF Send \r\n to the server
+
+ 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 are 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.
+
+ 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 are
+ the same as for keymap name.
+
+ You must define one with name 'default', which will be used as
+ default.
+
+ In the body of this section you can combine keymaps and set
+ the charmap. The format for this 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 (the default)
+ you can not define ': <vk_name> ...' part, but for the rest
+ (secondary) you must!
+ The ': <vk_name> ...' part defines a key for switch to this
+ keymap.
+
+ Assigning a switching key to the first (default) keymap will be
+ ignored, but you can switch to by pressing a second time the
+ switch key for the current keymap.
+
+ If a key is not found in a switched keymap, a program will
+ look for it in the default keymap. So, you only need to redefine
+ needed keys in secondary keymaps.
+
+ CHARMAP name
+
+ define which charmap 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
+ [end config]
+
+ For switching to russian keyboard just press RIGHT_ALT and '/'.
+ To switch back press it again.
+
+[end comment]
+
+[GLOBAL]
+; DO NOT MODIFY THE GLOBALS UNLESS YOU KNOW WHAT YOU ARE DOING.
+; The globals are required for the key translation to work.
+; do not place keymap before globals
+
+VK_LBUTTON 01 Left mouse button
+VK_RBUTTON 02 Right mouse button
+VK_CANCEL 03 Control-break processing
+VK_MBUTTON 04 Middle mouse button (three-button mouse)
+;-- 05-07 Undefined
+VK_BACK 08 BACKSPACE key
+VK_TAB 09 TAB key
+;-- 10-11 Undefined
+VK_CLEAR 12 CLEAR key
+VK_RETURN 13 ENTER key
+;-- 14-15 Undefined
+;VK_SHIFT 16 SHIFT key
+;VK_CONTROL 17 CTRL key
+;VK_MENU 18 ALT key
+
+VK_PAUSE 19 PAUSE key
+;VK_CAPITAL 20 CAPS LOCK key
+;-- 21-25 Reserved for Kanji systems
+;-- 26 Undefined
+VK_ESCAPE 27 ESC key
+;-- 28-31 Reserved for Kanji systems
+VK_SPACE 32 SPACEBAR
+VK_PGUP 33 PAGE UP key
+VK_PGDN 34 PAGE DOWN key
+VK_END 35 END key
+VK_HOME 36 HOME key
+VK_LEFT 37 LEFT ARROW key
+VK_UP 38 UP ARROW key
+VK_RIGHT 39 RIGHT ARROW key
+VK_DOWN 40 DOWN ARROW key
+VK_SELECT 41 SELECT key
+;-- 42 Original equipment manufacturer (OEM) specific
+VK_EXECUTE 43 EXECUTE key
+VK_SNAPSHOT 44 PRINT SCREEN key for Windows 3.0 and later
+VK_INSERT 45 INS key
+VK_DELETE 46 DEL key
+VK_HELP 47 HELP key
+VK_0 48 0 key
+VK_1 49 1 key
+VK_2 50 2 key
+VK_3 51 3 key
+VK_4 52 4 key
+VK_5 53 5 key
+VK_6 54 6 key
+VK_7 55 7 key
+VK_8 56 8 key
+VK_9 57 9 key
+;-- 58-64 Undefined
+VK_A 65 A key
+VK_B 66 B key
+VK_C 67 C key
+VK_D 68 D key
+VK_E 69 E key
+VK_F 70 F key
+VK_G 71 G key
+VK_H 72 H key
+VK_I 73 I key
+VK_J 74 J key
+VK_K 75 K key
+VK_L 76 L key
+VK_M 77 M key
+VK_N 78 N key
+VK_O 79 O key
+VK_P 80 P key
+VK_Q 81 Q key
+VK_R 82 R key
+VK_S 83 S key
+VK_T 84 T key
+VK_U 85 U key
+VK_V 86 V key
+VK_W 87 W key
+VK_X 88 X key
+VK_Y 89 Y key
+VK_Z 90 Z key
+;-- 91-95 Undefined
+VK_NUMPAD0 96 Numeric keypad 0 key
+VK_NUMPAD1 97 Numeric keypad 1 key
+VK_NUMPAD2 98 Numeric keypad 2 key
+VK_NUMPAD3 99 Numeric keypad 3 key
+VK_NUMPAD4 100 Numeric keypad 4 key
+VK_NUMPAD5 101 Numeric keypad 5 key
+VK_NUMPAD6 102 Numeric keypad 6 key
+VK_NUMPAD7 103 Numeric keypad 7 key
+VK_NUMPAD8 104 Numeric keypad 8 key
+VK_NUMPAD9 105 Numeric keypad 9 key
+VK_MULTIPLY 106 Multiply key
+VK_ADD 107 Add key
+VK_SEPARATOR 108 Separator key
+VK_SUBTRACT 109 Subtract key
+VK_DECIMAL 110 Decimal key
+VK_DIVIDE 111 Divide key
+VK_F1 112 F1 key
+VK_F2 113 F2 key
+VK_F3 114 F3 key
+VK_F4 115 F4 key
+VK_F5 116 F5 key
+VK_F6 117 F6 key
+VK_F7 118 F7 key
+VK_F8 119 F8 key
+VK_F9 120 F9 key
+VK_F10 121 F10 key
+VK_F11 122 F11 key
+VK_F12 123 F12 key
+VK_F13 124 F13 key
+VK_F14 125 F14 key
+VK_F15 126 F15 key
+VK_F16 127 F16 key
+VK_F17 128 F17 key
+VK_F18 129 F18 key
+VK_F19 130 F19 key
+VK_F20 131 F20 key
+VK_F21 132 F21 key
+VK_F22 133 F22 key
+VK_F23 134 F23 key
+VK_F24 135 F24 key
+;-- 136-143 Unassigned
+VK_NUMLOCK 144 NUM LOCK key
+VK_SCROLL 145 SCROLL LOCK key
+;-- 146-185 Unassigned
+
+;
+;
+; John Ioannou (roryt@hol.gr)
+; Athens 30/03/97 10:42pm GMT-2
+; Correction for Win95
+;
+; This keys are used (at least in my keyboard -737/437 cp)
+; for some common keys (equal, slash, backslash etc).
+; Normally we don't want to define them, but
+; there is a bug with win95 with them :
+; with CAPS LOCK on they produce the SHIFTED character
+; (minus gives _, = gives + etc).
+;
+;
+;-- 186-192 OEM specific
+VK_; 186 ;
+VK_= 187 EQUAL
+VK_, 188 ,
+VK_- 189 MINUS
+VK_. 190 FULLSTOP
+VK_/ 191 SLASH
+VK_` 192 `
+;-- 193-218 Unassigned
+;-- 219-228 OEM specific
+VK_[ 219 [
+VK_\ 220 BACKSLASH
+VK_] 221 ]
+VK_' 222 '
+;-- 229 Unassigned
+;-- 230 OEM specific
+;-- 231-232 Unassigned
+;-- 233-245 OEM specific
+;-- 246-254 Unassigned
+
+[END GLOBAL]
+
+[keymap ANSI]
+;
+; John Ioannou (roryt@hol.gr)
+; Athens 30/03/97 10:42pm GMT-2
+;
+; these are full (SCO and not only) ANSI
+; also they deal with the win95 bug and
+; give support for the Midnight Commander
+;
+;
+; function keys
+;
+VK_F1 ^[[M
+VK_F2 ^[[N
+VK_F3 ^[[O
+VK_F4 ^[[P
+VK_F5 ^[[Q
+VK_F6 ^[[R
+VK_F7 ^[[S
+VK_F8 ^[[T
+VK_F9 ^[[U
+VK_F10 ^[[V
+VK_F11 ^[[W
+VK_F12 ^[[X
+VK_F1 SHIFT ^[[Y
+VK_F2 SHIFT ^[[Z
+VK_F3 SHIFT ^[[a
+VK_F4 SHIFT ^[[b
+VK_F5 SHIFT ^[[c
+VK_F6 SHIFT ^[[d
+VK_F7 SHIFT ^[[e
+VK_F8 SHIFT ^[[f
+VK_F9 SHIFT ^[[g
+VK_F10 SHIFT ^[[h
+VK_F11 SHIFT ^[[i
+VK_F12 SHIFT ^[[j
+VK_F1 RIGHT_CTRL ^[[k
+VK_F2 RIGHT_CTRL ^[[l
+VK_F3 RIGHT_CTRL ^[[m
+VK_F4 RIGHT_CTRL ^[[n
+VK_F5 RIGHT_CTRL ^[[o
+VK_F6 RIGHT_CTRL ^[[p
+VK_F7 RIGHT_CTRL ^[[q
+VK_F8 RIGHT_CTRL ^[[r
+VK_F9 RIGHT_CTRL ^[[s
+VK_F10 RIGHT_CTRL ^[[t
+VK_F11 RIGHT_CTRL ^[[y
+VK_F12 RIGHT_CTRL ^[[v
+VK_F1 LEFT_CTRL ^[[k
+VK_F2 LEFT_CTRL ^[[l
+VK_F3 LEFT_CTRL ^[[m
+VK_F4 LEFT_CTRL ^[[n
+VK_F5 LEFT_CTRL ^[[o
+VK_F6 LEFT_CTRL ^[[p
+VK_F7 LEFT_CTRL ^[[q
+VK_F8 LEFT_CTRL ^[[r
+VK_F9 LEFT_CTRL ^[[s
+VK_F10 LEFT_CTRL ^[[t
+VK_F11 LEFT_CTRL ^[[y
+VK_F12 LEFT_CTRL ^[[v
+;
+; misc fuctions
+;
+; FIX ME!!! Some people have reported that these keys don't work.
+VK_SCROLL \017
+VK_PAUSE \019
+VK_INSERT ^[[L
+VK_DELETE ENHANCED \127
+VK_HOME ^[[H
+VK_PGUP ^[[I
+VK_PGDN ^[[G
+VK_END ^[[F
+VK_INSERT SHIFT ^[[L
+VK_DELETE SHIFT+ENHANCED \127
+VK_HOME SHIFT ^[[H
+VK_PGUP SHIFT ^[[I
+VK_PGDN SHIFT ^[[G
+VK_END SHIFT ^[[F
+;
+; arrows
+;
+VK_LEFT ^[[D
+VK_UP ^[[A
+VK_RIGHT ^[[C
+VK_DOWN ^[[B
+VK_LEFT SHIFT ^[[D
+VK_UP SHIFT ^[[A
+VK_RIGHT SHIFT ^[[C
+VK_DOWN SHIFT ^[[B
+;
+; just in case !!!
+;
+VK_ESCAPE SHIFT \027
+VK_TAB \009
+VK_TAB SHIFT ^[[Z^[[Z
+;
+;---------------------------------------
+; Athens 30/03/97 10:55pm GMT+2
+; Correction for Win95
+;
+VK_6 SHIFT \094
+VK_` `
+VK_` SHIFT ~
+VK_0 CAPSLOCK 0
+VK_1 CAPSLOCK 1
+VK_2 CAPSLOCK 2
+VK_3 CAPSLOCK 3
+VK_4 CAPSLOCK 4
+VK_5 CAPSLOCK 5
+VK_6 CAPSLOCK 6
+VK_7 CAPSLOCK 7
+VK_8 CAPSLOCK 8
+VK_9 CAPSLOCK 9
+VK_ESCAPE CAPSLOCK \027
+VK_` CAPSLOCK `
+VK_= CAPSLOCK =
+VK_- CAPSLOCK -
+VK_\ CAPSLOCK \
+VK_[ CAPSLOCK [
+VK_] CAPSLOCK ]
+VK_; CAPSLOCK ;
+VK_' CAPSLOCK '
+VK_, CAPSLOCK ,
+VK_. CAPSLOCK .
+VK_/ CAPSLOCK /
+VK_0 CAPSLOCK+SHIFT )
+VK_1 CAPSLOCK+SHIFT !
+VK_2 CAPSLOCK+SHIFT @
+VK_3 CAPSLOCK+SHIFT #
+VK_4 CAPSLOCK+SHIFT $
+VK_5 CAPSLOCK+SHIFT %
+VK_6 CAPSLOCK+SHIFT ^
+VK_7 CAPSLOCK+SHIFT &
+VK_8 CAPSLOCK+SHIFT *
+VK_9 CAPSLOCK+SHIFT (
+VK_ESCAPE CAPSLOCK+SHIFT \027
+VK_` CAPSLOCK+SHIFT ~
+VK_= CAPSLOCK+SHIFT +
+VK_- CAPSLOCK+SHIFT _
+VK_\ CAPSLOCK+SHIFT |
+VK_[ CAPSLOCK+SHIFT {
+VK_] CAPSLOCK+SHIFT }
+VK_; CAPSLOCK+SHIFT :
+VK_' CAPSLOCK+SHIFT "
+VK_, CAPSLOCK+SHIFT <
+VK_. CAPSLOCK+SHIFT >
+VK_/ CAPSLOCK+SHIFT ?
+;
+;
+;---------------------------------------
+;
+; These are for use with Midnight Commander
+; they map Meta key to ALT (Like Linux console, nice isn't it ? )
+;
+VK_0 RIGHT_ALT ^[0
+VK_1 RIGHT_ALT ^[1
+VK_2 RIGHT_ALT ^[2
+VK_3 RIGHT_ALT ^[3
+VK_4 RIGHT_ALT ^[4
+VK_5 RIGHT_ALT ^[5
+VK_6 RIGHT_ALT ^[6
+VK_7 RIGHT_ALT ^[7
+VK_8 RIGHT_ALT ^[8
+VK_9 RIGHT_ALT ^[9
+VK_A RIGHT_ALT ^[A
+VK_B RIGHT_ALT ^[B
+VK_C RIGHT_ALT ^[C
+VK_D RIGHT_ALT ^[D
+VK_E RIGHT_ALT ^[E
+VK_F RIGHT_ALT ^[F
+VK_G RIGHT_ALT ^[G
+VK_H RIGHT_ALT ^[H
+VK_I RIGHT_ALT ^[I
+VK_J RIGHT_ALT ^[J
+VK_K RIGHT_ALT ^[K
+VK_L RIGHT_ALT ^[L
+VK_M RIGHT_ALT ^[M
+VK_N RIGHT_ALT ^[N
+VK_O RIGHT_ALT ^[O
+VK_P RIGHT_ALT ^[P
+VK_Q RIGHT_ALT ^[Q
+VK_R RIGHT_ALT ^[R
+VK_S RIGHT_ALT ^[S
+VK_T RIGHT_ALT ^[T
+VK_U RIGHT_ALT ^[U
+VK_V RIGHT_ALT ^[V
+VK_W RIGHT_ALT ^[W
+VK_X RIGHT_ALT ^[X
+VK_Y RIGHT_ALT ^[Y
+VK_Z RIGHT_ALT ^[Z
+VK_0 LEFT_ALT ^[0
+VK_1 LEFT_ALT ^[1
+VK_2 LEFT_ALT ^[2
+VK_3 LEFT_ALT ^[3
+VK_4 LEFT_ALT ^[4
+VK_5 LEFT_ALT ^[5
+VK_6 LEFT_ALT ^[6
+VK_7 LEFT_ALT ^[7
+VK_8 LEFT_ALT ^[8
+VK_9 LEFT_ALT ^[9
+VK_A LEFT_ALT ^[a
+VK_B LEFT_ALT ^[b
+VK_C LEFT_ALT ^[c
+VK_D LEFT_ALT ^[d
+VK_E LEFT_ALT ^[e
+VK_F LEFT_ALT ^[f
+VK_G LEFT_ALT ^[g
+VK_H LEFT_ALT ^[h
+VK_I LEFT_ALT ^[i
+VK_J LEFT_ALT ^[j
+VK_K LEFT_ALT ^[k
+VK_L LEFT_ALT ^[l
+VK_M LEFT_ALT ^[m
+VK_N LEFT_ALT ^[n
+VK_O LEFT_ALT ^[o
+VK_P LEFT_ALT ^[p
+VK_Q LEFT_ALT ^[q
+VK_R LEFT_ALT ^[r
+VK_S LEFT_ALT ^[s
+VK_T LEFT_ALT ^[t
+VK_U LEFT_ALT ^[u
+VK_V LEFT_ALT ^[v
+VK_W LEFT_ALT ^[w
+VK_X LEFT_ALT ^[x
+VK_Y LEFT_ALT ^[y
+VK_Z LEFT_ALT ^[z
+VK_RETURN RIGHT_CTRL \TN_CR
+VK_RETURN LEFT_CTRL \TN_CR
+; VK_RETURN now sends CR except in newline mode (Paul Brannan 12/9/98)
+VK_RETURN \TN_CR
+VK_RETURN APP4_KEY \TN_CRLF
+VK_RETURN ENHANCED \TN_CR
+; This is for application cursor keys (Paul Brannan 5/27/98)
+VK_LEFT APP_KEY ^[OD
+VK_UP APP_KEY ^[OA
+VK_RIGHT APP_KEY ^[OC
+VK_DOWN APP_KEY ^[OB
+VK_LEFT APP_KEY+SHIFT ^[OD
+VK_UP APP_KEY+SHIFT ^[OA
+VK_RIGHT APP_KEY+SHIFT ^[OC
+VK_DOWN APP_KEY+SHIFT ^[OB
+; APP2_KEY is for VT52 support (Paul Brannan 6/28/98)
+VK_LEFT APP2_KEY ^[D
+VK_UP APP2_KEY ^[A
+VK_RIGHT APP2_KEY ^[C
+VK_DOWN APP2_KEY ^[B
+VK_LEFT APP2_KEY+SHIFT ^[D
+VK_UP APP2_KEY+SHIFT ^[A
+VK_RIGHT APP2_KEY+SHIFT ^[C
+VK_DOWN APP2_KEY+SHIFT ^[B
+VK_F1 APP2_KEY ^[P
+VK_F2 APP2_KEY ^[Q
+VK_F3 APP2_KEY ^[R
+VK_F4 APP2_KEY ^[S
+VK_F5 APP2_KEY ^[?w
+VK_F6 APP2_KEY ^[?x
+VK_F7 APP2_KEY ^[?y
+VK_F8 APP2_KEY ^[?m
+VK_F9 APP2_KEY ^[?t
+VK_F10 APP2_KEY ^[?u
+VK_F1 APP2_KEY+SHIFT ^[?v
+VK_F2 APP2_KEY+SHIFT ^[?l
+VK_F3 APP2_KEY+SHIFT ^[?q
+VK_F4 APP2_KEY+SHIFT ^[?r
+VK_F5 APP2_KEY+SHIFT ^[?s
+VK_F6 APP2_KEY+SHIFT ^[?M
+VK_F7 APP2_KEY+SHIFT ^[?p
+VK_F8 APP2_KEY+SHIFT ^[?n
+
+; Fix for the numeric decimal key (Paul Brannan 9/23/98)
+VK_DELETE \127
+VK_DELETE NUMLOCK .
+VK_DELETE NUMLOCK+SHIFT \127
+
+; VT100 Application keypad mode (Paul Brannan 12/8/98)
+VK_NUMPAD0 APP3_KEY ^[Op
+VK_NUMPAD1 APP3_KEY ^[Oq
+VK_NUMPAD2 APP3_KEY ^[Or
+VK_NUMPAD3 APP3_KEY ^[Os
+VK_NUMPAD4 APP3_KEY ^[Ot
+VK_NUMPAD5 APP3_KEY ^[Ou
+VK_NUMPAD6 APP3_KEY ^[Ov
+VK_NUMPAD7 APP3_KEY ^[Ow
+VK_NUMPAD8 APP3_KEY ^[Ox
+VK_NUMPAD9 APP3_KEY ^[Oy
+VK_ADD APP3_KEY ^[Ol
+VK_SUBTRACT APP3_KEY ^[Om
+VK_DELETE APP3_KEY ^[On
+VK_RETURN ENHANCED+APP3_KEY ^[OM
+
+; VT52 Application keypad mode (Paul Brannan 12/8/98)
+VK_NUMPAD0 APP2_KEY+APP3_KEY ^[?p
+VK_NUMPAD1 APP2_KEY+APP3_KEY ^[?q
+VK_NUMPAD2 APP2_KEY+APP3_KEY ^[?r
+VK_NUMPAD3 APP2_KEY+APP3_KEY ^[?s
+VK_NUMPAD4 APP2_KEY+APP3_KEY ^[?t
+VK_NUMPAD5 APP2_KEY+APP3_KEY ^[?u
+VK_NUMPAD6 APP2_KEY+APP3_KEY ^[?v
+VK_NUMPAD7 APP2_KEY+APP3_KEY ^[?w
+VK_NUMPAD8 APP2_KEY+APP3_KEY ^[?x
+VK_NUMPAD9 APP2_KEY+APP3_KEY ^[?y
+VK_ADD APP2_KEY+APP3_KEY ^[?l
+VK_SUBTRACT APP2_KEY+APP3_KEY ^[?m
+VK_DELETE APP2_KEY+APP3_KEY ^[?n
+VK_RETURN ENHANCED+APP2_KEY+APP3_KEY ^[?M
+
+; Extra control characters (Paul Brannan 12/10/98)
+VK_2 LEFT_CTRL \x00\x00
+VK_2 RIGHT_CTRL \x00\x00
+VK_6 LEFT_CTRL \x1e
+VK_6 RIGHT_CTRL \x1e
+VK_- LEFT_CTRL \x1f
+VK_- RIGHT_CTRL \x1f
+
+; A way to send the null Character (Paul Brannan 3/29/00)
+VK_SPACE LEFT_CTRL \TN_NULL
+VK_SPACE RIGHT_CTRL \TN_NULL
+
+[END keymap] // ansi
+
+[keymap LINUX]
+;
+;
+; John Ioannou (roryt@hol.gr)
+; Athens 12 April 1997
+;
+; Linux keys
+;
+; Andrew Smilianets (smile@head.aval.kiev.ua)
+; Kiev 23 December 1997
+;
+; duplicated with default stripped, so, to use it, declare
+; keymap default+linux
+
+;
+; function keys
+;
+VK_F1 ^[[[A
+VK_F2 ^[[[B
+VK_F3 ^[[[C
+VK_F4 ^[[[D
+VK_F5 ^[[[E
+VK_F6 ^[[17~
+VK_F7 ^[[18~
+VK_F8 ^[[19~
+VK_F9 ^[[20~
+VK_F10 ^[[21~
+VK_F11 ^[[23~
+VK_F12 ^[[24~
+VK_F1 SHIFT ^[[23~
+VK_F2 SHIFT ^[[24~
+VK_F3 SHIFT ^[[25~
+VK_F4 SHIFT ^[[26~
+VK_F5 SHIFT ^[[28~
+VK_F6 SHIFT ^[[29~
+VK_F7 SHIFT ^[[31~
+VK_F8 SHIFT ^[[32~
+VK_F9 SHIFT ^[[33~
+VK_F10 SHIFT ^[[34~
+VK_F11 SHIFT ^[[23~
+VK_F12 SHIFT ^[[24~
+VK_F1 RIGHT_CTRL ^[[[A
+VK_F2 RIGHT_CTRL ^[[[B
+VK_F3 RIGHT_CTRL ^[[[C
+VK_F4 RIGHT_CTRL ^[[[D
+VK_F5 RIGHT_CTRL ^[[[E
+VK_F6 RIGHT_CTRL ^[[17~
+VK_F7 RIGHT_CTRL ^[[18~
+VK_F8 RIGHT_CTRL ^[[19~
+VK_F9 RIGHT_CTRL ^[[20~
+VK_F10 RIGHT_CTRL ^[[21~
+VK_F11 RIGHT_CTRL ^[[23~
+VK_F12 RIGHT_CTRL ^[[24~
+VK_F1 LEFT_CTRL ^[[[A
+VK_F2 LEFT_CTRL ^[[[B
+VK_F3 LEFT_CTRL ^[[[C
+VK_F4 LEFT_CTRL ^[[[D
+VK_F5 LEFT_CTRL ^[[[E
+VK_F6 LEFT_CTRL ^[[17~
+VK_F7 LEFT_CTRL ^[[18~
+VK_F8 LEFT_CTRL ^[[19~
+VK_F9 LEFT_CTRL ^[[20~
+VK_F10 LEFT_CTRL ^[[21~
+VK_F11 LEFT_CTRL ^[[23~
+VK_F12 LEFT_CTRL ^[[24~
+;
+; misc fuctions
+;
+VK_PAUSE ^[[P
+VK_INSERT ^[[2~
+VK_DELETE ENHANCED ^[[3~
+VK_HOME ^[[1~
+VK_PGUP ^[[5~
+VK_PGDN ^[[6~
+VK_END ^[[4~
+VK_INSERT SHIFT ^[[2~
+VK_DELETE SHIFT+ENHANCED ^[[3~
+VK_HOME SHIFT ^[[1~
+VK_PGUP SHIFT ^[[5~
+VK_PGDN SHIFT ^[[6~
+VK_END SHIFT ^[[4~
+VK_INSERT LEFT_CTRL ^[[2~
+VK_DELETE LEFT_CTRL ^[[3~
+VK_HOME LEFT_CTRL ^[[1~
+VK_PGUP LEFT_CTRL ^[[5~
+VK_PGDN LEFT_CTRL ^[[6~
+VK_END LEFT_CTRL ^[[4~
+VK_INSERT RIGHT_CTRL ^[[2~
+VK_DELETE RIGHT_CTRL ^[[3~
+VK_HOME RIGHT_CTRL ^[[1~
+VK_PGUP RIGHT_CTRL ^[[5~
+VK_PGDN RIGHT_CTRL ^[[6~
+VK_END RIGHT_CTRL ^[[4~
+;
+; arrows
+;
+VK_UP RIGHT_CTRL ^[[A
+VK_DOWN RIGHT_CTRL ^[[B
+VK_RIGHT RIGHT_CTRL ^[[C
+VK_LEFT RIGHT_CTRL ^[[D
+VK_UP LEFT_CTRL ^[[A
+VK_DOWN LEFT_CTRL ^[[B
+VK_RIGHT LEFT_CTRL ^[[C
+VK_LEFT LEFT_CTRL ^[[D
+VK_NUMPAD5 ^[[G
+
+[END keymap] // linux
+
+[keymap vt100]
+; These were wrong, according to the docs I have. They don't work with
+; Midnight Commander on my machine. I'm not sure if
+; this is correct or not. I've also changed F1 - F4 so that they
+; send PF1 - PF4, and F5 - F10 so they send VT102 application mode
+; DEC keypad sequences. I changed SF1 - SF10 so they akso send DEC keypad
+; sequences, and CF6 - CF12 so they send VT320 keypad sequences.
+; (Paul Brannan 6/28/98)
+;
+; The numpad keys seem to be wrong, too. This has been fixed.
+; (Paul Brannan 12/8/98)
+VK_F1 ^[OP
+VK_F2 ^[OQ
+VK_F3 ^[OR
+VK_F4 ^[OS
+VK_F5 ^[Ow
+VK_F6 ^[Ox
+VK_F7 ^[Oy
+VK_F8 ^[Om
+VK_F9 ^[Ot
+VK_F10 ^[Ou
+VK_F1 SHIFT ^[Ov
+VK_F2 SHIFT ^[Ol
+VK_F3 SHIFT ^[Oq
+VK_F4 SHIFT ^[Or
+VK_F5 SHIFT ^[Os
+VK_F6 SHIFT ^[OM
+VK_F7 SHIFT ^[Op
+VK_F8 SHIFT ^[On
+VK_F6 RIGHT_CTRL ^[[17~
+VK_F7 RIGHT_CTRL ^[[18~
+VK_F8 RIGHT_CTRL ^[[19~
+VK_F9 RIGHT_CTRL ^[[20~
+VK_F10 RIGHT_CTRL ^[[21~
+VK_F11 RIGHT_CTRL ^[[23~
+VK_F12 RIGHT_CTRL ^[[24~
+VK_F6 LEFT_CTRL ^[[17~
+VK_F7 LEFT_CTRL ^[[18~
+VK_F8 LEFT_CTRL ^[[19~
+VK_F9 LEFT_CTRL ^[[20~
+VK_F10 LEFT_CTRL ^[[21~
+VK_F11 LEFT_CTRL ^[[23~
+VK_F12 LEFT_CTRL ^[[24~
+
+[END keymap] // vt100
+
+[keymap AT386]
+:
+; AT386 extended keys
+;
+; Dmitry Lapenkov <dl@bis.ru>
+;
+
+VK_LBUTTON ^M\x00
+VK_RBUTTON ^[^[
+VK_CANCEL ^C
+VK_MBUTTON ^[OP
+VK_BACK ^H
+VK_BACK SHIFT ^[[O
+VK_BACK LEFT_CTRL \127
+VK_BACK RIGHT_CTRL \127
+VK_TAB ^I
+VK_TAB SHIFT ^[[Z
+VK_TAB LEFT_CTRL ^[[Z
+VK_TAB RIGHT_CTRL ^[[Z
+VK_RETURN ^M\x00
+VK_RETURN SHIFT ^[[R
+VK_RETURN LEFT_CTRL ^J
+VK_RETURN RIGHT_CTRL ^J
+VK_PAUSE ^S
+VK_PAUSE LEFT_CTRL ^C
+VK_PAUSE RIGHT_CTRL ^C
+VK_PAUSE SHIFT ^S
+VK_ESCAPE ^[^[
+VK_ESCAPE SHIFT ^[
+VK_BACK LEFT_ALT ^[[o
+VK_BACK RIGHT_ALT ^[[o
+VK_TAB LEFT_ALT ^[[z
+VK_TAB RIGHT_ALT ^[[z
+VK_RETURN LEFT_ALT ^[[r
+VK_RETURN RIGHT_ALT ^[[r
+VK_PAUSE LEFT_ALT ^[<
+VK_PAUSE RIGHT_ALT ^[>
+VK_PGUP ^[[V
+VK_PGUP SHIFT ^[[V
+VK_PGUP LEFT_CTRL ^[[W
+VK_PGUP RIGHT_CTRL ^[[W
+VK_PGDN ^[[U
+VK_PGDN SHIFT ^[[U
+VK_PGDN LEFT_CTRL ^[[X
+VK_PGDN RIGHT_CTRL ^[[X
+VK_END ^[[Y
+VK_END SHIFT ^[[Y
+VK_END LEFT_CTRL ^[[E
+VK_END RIGHT_CTRL ^[[E
+VK_HOME ^[[H
+VK_HOME SHIFT ^[[H
+VK_HOME LEFT_CTRL ^[[F
+VK_HOME RIGHT_CTRL ^[[F
+VK_LEFT ^[[D
+VK_LEFT SHIFT ^[[D
+VK_LEFT LEFT_CTRL ^[[K
+VK_LEFT RIGHT_CTRL ^[[K
+VK_UP ^[[A
+VK_UP SHIFT ^[[A
+VK_UP LEFT_CTRL ^[[I
+VK_UP RIGHT_CTRL ^[[I
+VK_RIGHT ^[[C
+VK_RIGHT SHIFT ^[[C
+VK_RIGHT LEFT_CTRL ^[[L
+VK_RIGHT RIGHT_CTRL ^[[L
+VK_DOWN ^[[B
+VK_DOWN SHIFT ^[[B
+VK_DOWN LEFT_CTRL ^[[J
+VK_DOWN RIGHT_CTRL ^[[J
+VK_INSERT ^[[@
+VK_INSERT SHIFT ^[[T
+VK_INSERT LEFT_CTRL ^[[T
+VK_INSERT RIGHT_CTRL ^[[T
+VK_DELETE \127
+VK_DELETE SHIFT ^[[S
+VK_DELETE LEFT_CTRL ^[[S
+VK_DELETE RIGHT_CTRL ^[[S
+VK_PGUP LEFT_ALT ^[[v
+VK_PGUP RIGHT_ALT ^[[v
+VK_PGDN LEFT_ALT ^[[u
+VK_PGDN RIGHT_ALT ^[[u
+VK_END LEFT_ALT ^[[y
+VK_END RIGHT_ALT ^[[y
+VK_HOME LEFT_ALT ^[[h
+VK_HOME RIGHT_ALT ^[[h
+VK_LEFT LEFT_ALT ^[[d
+VK_LEFT RIGHT_ALT ^[[d
+VK_UP LEFT_ALT ^[[a
+VK_UP RIGHT_ALT ^[[a
+VK_RIGHT LEFT_ALT ^[[c
+VK_RIGHT RIGHT_ALT ^[[c
+VK_DOWN LEFT_ALT ^[[b
+VK_DOWN RIGHT_ALT ^[[b
+VK_INSERT LEFT_ALT ^[[t
+VK_INSERT RIGHT_ALT ^[[t
+VK_DELETE LEFT_ALT ^[[s
+VK_DELETE RIGHT_ALT ^[[s
+VK_0 LEFT_ALT ^[N0
+VK_1 LEFT_ALT ^[N1
+VK_2 LEFT_ALT ^[N2
+VK_3 LEFT_ALT ^[N3
+VK_4 LEFT_ALT ^[N4
+VK_5 LEFT_ALT ^[N5
+VK_6 LEFT_ALT ^[N6
+VK_7 LEFT_ALT ^[N7
+VK_8 LEFT_ALT ^[N8
+VK_9 LEFT_ALT ^[N9
+VK_0 RIGHT_ALT ^[N0
+VK_1 RIGHT_ALT ^[N1
+VK_2 RIGHT_ALT ^[N2
+VK_3 RIGHT_ALT ^[N3
+VK_4 RIGHT_ALT ^[N4
+VK_5 RIGHT_ALT ^[N5
+VK_6 RIGHT_ALT ^[N6
+VK_7 RIGHT_ALT ^[N7
+VK_8 RIGHT_ALT ^[N8
+VK_9 RIGHT_ALT ^[N9
+VK_A LEFT_ALT ^[NA
+VK_B LEFT_ALT ^[NB
+VK_C LEFT_ALT ^[NC
+VK_D LEFT_ALT ^[ND
+VK_E LEFT_ALT ^[NE
+VK_F LEFT_ALT ^[NF
+VK_G LEFT_ALT ^[NG
+VK_H LEFT_ALT ^[NH
+VK_I LEFT_ALT ^[NI
+VK_J LEFT_ALT ^[NJ
+VK_K LEFT_ALT ^[NK
+VK_L LEFT_ALT ^[NL
+VK_M LEFT_ALT ^[NM
+VK_M LEFT_ALT ^[NN
+VK_O LEFT_ALT ^[NO
+VK_P LEFT_ALT ^[NP
+VK_Q LEFT_ALT ^[NQ
+VK_R LEFT_ALT ^[NR
+VK_S LEFT_ALT ^[NS
+VK_T LEFT_ALT ^[NT
+VK_U LEFT_ALT ^[NU
+VK_V LEFT_ALT ^[NV
+VK_W LEFT_ALT ^[NW
+VK_X LEFT_ALT ^[NX
+VK_Y LEFT_ALT ^[NY
+VK_Z LEFT_ALT ^[NZ
+VK_A RIGHT_ALT ^[NA
+VK_B RIGHT_ALT ^[NB
+VK_C RIGHT_ALT ^[NC
+VK_D RIGHT_ALT ^[ND
+VK_E RIGHT_ALT ^[NE
+VK_F RIGHT_ALT ^[NF
+VK_G RIGHT_ALT ^[NG
+VK_H RIGHT_ALT ^[NH
+VK_I RIGHT_ALT ^[NI
+VK_J RIGHT_ALT ^[NJ
+VK_K RIGHT_ALT ^[NK
+VK_L RIGHT_ALT ^[NL
+VK_M RIGHT_ALT ^[NM
+VK_M RIGHT_ALT ^[NN
+VK_O RIGHT_ALT ^[NO
+VK_P RIGHT_ALT ^[NP
+VK_Q RIGHT_ALT ^[NQ
+VK_R RIGHT_ALT ^[NR
+VK_S RIGHT_ALT ^[NS
+VK_T RIGHT_ALT ^[NT
+VK_U RIGHT_ALT ^[NU
+VK_V RIGHT_ALT ^[NV
+VK_W RIGHT_ALT ^[NW
+VK_X RIGHT_ALT ^[NX
+VK_Y RIGHT_ALT ^[NY
+VK_Z RIGHT_ALT ^[NZ
+VK_NUMPAD0 LEFT_CTRL ^[[T
+VK_NUMPAD0 RIGHT_CTRL ^[[T
+VK_NUMPAD1 LEFT_CTRL ^[[E
+VK_NUMPAD1 RIGHT_CTRL ^[[E
[truncated at 1000 lines; 1620 more skipped]
reactos/apps/utils/net/telnet
diff -N telnet.ini
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ telnet.ini 21 Nov 2004 22:24:55 -0000 1.1
@@ -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
reactos/apps/utils/net/telnet
diff -u -r1.2 -r1.3
--- .cvsignore 29 Jun 2003 21:12:23 -0000 1.2
+++ .cvsignore 21 Nov 2004 22:24:55 -0000 1.3
@@ -1,6 +1,17 @@
+*.sys
+*.exe
+*.dll
+*.cpl
+*.a
*.o
*.d
-*.exe
*.coff
+*.dsp
+*.dsw
+*.aps
+*.ncb
+*.opt
*.sym
+*.plg
+*.bak
*.map
reactos/apps/utils/net/telnet
diff -u -r1.5 -r1.6
--- Makefile 7 Jun 2002 22:58:02 -0000 1.5
+++ Makefile 21 Nov 2004 22:24:55 -0000 1.6
@@ -1,5 +1,3 @@
-# $Id: Makefile,v 1.5 2002/06/07 22:58:02 ekohl Exp $
-
PATH_TO_TOP = ../../../..
TARGET_TYPE = program
@@ -8,19 +6,34 @@
TARGET_NAME = telnet
-TARGET_SDKLIBS = kernel32.a ws2_32.a
+TARGET_SDKLIBS = ws2_32.a
+
+TARGET_CPPFLAGS = -D__REACTOS__ -D__USE_W32API -Wall
+
+TARGET_GCCLIBS = stdc++
TARGET_OBJECTS = \
- ansi.o \
- console.o \
- helpsock.o \
- main.o \
- nvt.o \
- telnet.o \
- vm.o
+ src/ansiprsr.o \
+ src/keytrans.o \
+ src/tcharmap.o \
+ src/tconsole.o \
+ src/tkeydef.o \
+ src/tkeymap.o \
+ src/tmapldr.o \
+ src/tmouse.o \
+ src/tnclass.o \
+ src/tnclip.o \
+ src/tncon.o \
+ src/tnconfig.o \
+ src/tnerror.o \
+ src/tnetwork.o \
+ src/tnmain.o \
+ src/tnmisc.o \
+ src/tscript.o \
+ src/tscroll.o \
+ src/ttelhndl.o
+
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
-
-# EOF
reactos/apps/utils/net/telnet
diff -u -r1.2 -r1.3
--- telnet.rc 16 Oct 2004 20:27:20 -0000 1.2
+++ telnet.rc 21 Nov 2004 22:24:55 -0000 1.3
@@ -1,6 +1,6 @@
-/* $Id: telnet.rc,v 1.2 2004/10/16 20:27:20 gvg Exp $ */
+/* $Id: telnet.rc,v 1.3 2004/11/21 22:24:55 chorns Exp $ */
-#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Telnet Win32 Client\0"
+#define REACTOS_STR_FILE_DESCRIPTION "Console Telnet for Win32\0"
#define REACTOS_STR_INTERNAL_NAME "telnet\0"
#define REACTOS_STR_ORIGINAL_FILENAME "telnet.exe\0"
#include <reactos/version.rc>
reactos/apps/utils/net/telnet
diff -N ansi.cpp
--- ansi.cpp 27 Jan 2001 22:38:43 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,307 +0,0 @@
-/* $Id: ansi.cpp,v 1.1 2001/01/27 22:38:43 ea Exp $
- *
- * FILE : ansi.cpp
- * AUTHOR : unknown (sources found on www.telnet.org)
- * PROJECT : ReactOS Operating System
- * DESCRIPTION: telnet client for the W32 subsystem
- * DATE : 2001-01-21
- * REVISIONS
- * 2001-02-21 ea Modified to compile under 0.0.16 src tree
- */
-#include <winsock.h>
-#include <windows.h>
-
-#include "telnet.h"
-
-// Need to implement a Keymapper.
-// here are some example key maps
-
-// vt100 f1 - \eOP
-// vt100 f2 - \eOQ
-
-// ansi f5 - \e[17~
-// f6 - \e[18~
-// f7 - \e[20~
-// f10- \e[[V
-
-enum _ansi_state
-{
- as_normal,
- as_esc,
- as_esc1
-};
-
-//SetConsoleMode
-
-///////////////////////////////////////////////////////////////////////////////
-// SET SCREEN ATTRIBUTE
-/*
-ESC [ Ps..Ps m Ps refers to selective parameter. Multiple parameters are
- separated by the semicolon character (073 octal). The param-
- eters are executed in order and have the following meaning:
-
- 0 or none All attributes off
- 1 Bold on
- 4 Underscore on
- 5 Blink on
- 7 Reverse video on
-
- 3x set foreground color to x
- nx set background color to x
-
- Any other parameters are ignored.
-*/
-static int sa = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
-
-void ansi_set_screen_attribute(char* buffer)
-{
- while(*buffer)
- {
- switch(*buffer++)
- {
- case '0': //Normal
- sa = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
- break;
- case '1': //Hign Intensity
- sa |= FOREGROUND_INTENSITY;
- break;
- case '4': //Underscore
- break;
- case '5': //Blink.
- sa |= BACKGROUND_INTENSITY;
- break;
- case '7':
- sa = BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE;
- break;
- case '8':
- sa = 0;
- break;
- case '3':
- sa = sa & (BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY) |
- (*buffer & 1)?FOREGROUND_RED:0 |
- (*buffer & 2)?FOREGROUND_GREEN:0 |
- (*buffer & 4)?FOREGROUND_BLUE:0;
- if(*buffer)
- buffer++;
- break;
- case '6':
- sa = sa & (FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY) |
- (*buffer & 1)?BACKGROUND_RED:0 |
- (*buffer & 2)?BACKGROUND_GREEN:0 |
- (*buffer & 4)?BACKGROUND_BLUE:0;
- if(*buffer)
- buffer++;
- break;
- }
- if(*buffer && *buffer == ';')
- buffer++;
- }
- SetConsoleTextAttribute(StandardOutput,sa);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// ERASE LINE
-/*
-ESC [ 0K Same *default*
-ESC [ 1K Erase from beginning of line to cursor
-ESC [ 2K Erase line containing cursor
-*/
-
-void ansi_erase_line(char* buffer)
-{
- int act = 0;
- while(*buffer)
- {
- act = (*buffer++) - '0';
- }
-
- CONSOLE_SCREEN_BUFFER_INFO csbi;
- GetConsoleScreenBufferInfo(StandardOutput,&csbi);
-
- COORD pos;
- DWORD n;
-
- switch(act)
- {
- case 0: //erase to end of line
- pos.X = csbi.dwCursorPosition.X;
- pos.Y = csbi.dwCursorPosition.Y;
- n = csbi.dwSize.X - csbi.dwCursorPosition.X;
- break;
- case 1: //erase from beginning
- pos.X = 0;
- pos.Y = csbi.dwCursorPosition.Y;
- n = csbi.dwCursorPosition.X;
- break;
- case 2: // erase whole line
- pos.X = 0;
- pos.Y = csbi.dwCursorPosition.Y;
- n = csbi.dwSize.X;
- break;
- }
-
- DWORD w;
- FillConsoleOutputCharacter(StandardOutput,' ',n,pos,&w);
-}
-
-
-///////////////////////////////////////////////////////////////////////////////
-// SET POSITION
-// ESC [ Pl;PcH Direct cursor addressing, where Pl is line#, Pc is column#
-// default = (1,1)
-
-void ansi_set_position(char* buffer)
-{
- COORD pos = {0,0};
-
- // Grab line
- while(*buffer && *buffer != ';')
- pos.Y = pos.Y*10 + *buffer++ - '0';
-
- if(*buffer)
- buffer++;
-
- // Grab y
- while(*buffer && *buffer != ';')
- pos.X = pos.X*10 + *buffer++ - '0';
-
- (pos.X)?pos.X--:0;
- (pos.Y)?pos.Y--:0;
-
- SetConsoleCursorPosition(StandardOutput,pos);
-
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// ERASE SCREEN
-/*
-ESC [ 0J Same *default*
-ESC [ 2J Erase entire screen
-*/
-
-void ansi_erase_screen(char* buffer)
-{
- int act = 0;
- while(*buffer)
- {
- act = (*buffer++) - '0';
- }
-
- CONSOLE_SCREEN_BUFFER_INFO csbi;
- GetConsoleScreenBufferInfo(StandardOutput,&csbi);
-
- COORD pos;
- DWORD n;
-
- switch(act)
- {
- case 0:
- pos.X = csbi.dwCursorPosition.X;
- pos.Y = csbi.dwCursorPosition.Y;
- n = csbi.dwSize.X*csbi.dwSize.Y;
- break;
- case 2:
- pos.X = 0;
- pos.Y = 0;
- n = csbi.dwSize.X*csbi.dwSize.Y;
- break;
- }
-
- DWORD w;
- FillConsoleOutputCharacter(StandardOutput,' ',n,pos,&w);
- SetConsoleCursorPosition(StandardOutput,pos);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// MOVE UP
-// ESC [ Pn A Cursor up Pn lines (Pn default=1)
-
-void ansi_move_up(char* buffer)
-{
- int cnt = *buffer?0:1;
- while(*buffer)
- {
- cnt = cnt*10 + (*buffer++) - '0';
- }
-
- COORD pos;
-
- CONSOLE_SCREEN_BUFFER_INFO csbi;
- GetConsoleScreenBufferInfo(StandardOutput,&csbi);
-
- pos.X = csbi.dwCursorPosition.X;
- pos.Y = ((csbi.dwCursorPosition.Y-cnt)>=0)?(csbi.dwCursorPosition.Y-cnt):0;
-
- SetConsoleCursorPosition(StandardOutput,pos);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-char codebuf[256];
-unsigned char codeptr;
-
-#define NUM_CODEC 6
-
-typedef void (*LPCODEPROC)(char*);
-
-struct
-{
- unsigned char cmd;
- LPCODEPROC proc;
-} codec[NUM_CODEC] = {
- {'m',ansi_set_screen_attribute},
- {'H',ansi_set_position},
- {'K',ansi_erase_line},
- {'J',ansi_erase_screen},
- {'A',ansi_move_up},
- {0,0}
-};
-
-void ansi(SOCKET server,unsigned char data)
-{
- static _ansi_state state = as_normal;
- DWORD z;
- switch( state)
- {
- case as_normal:
- switch(data)
- {
- case 0: //eat null codes.
- break;
- case 27: //ANSI esc.
- state = as_esc;
- break;
- default: //Send all else to the console.
- WriteConsole(StandardOutput,&data,1,&z,NULL);
- break;
- }
- break;
- case as_esc:
- state = as_esc1;
- codeptr=0;
- codebuf[codeptr] = 0;
- break;
- case as_esc1:
- if(data > 64)
- {
- int i = 0;
- codebuf[codeptr] = 0;
- for(i=0; codec[i].cmd && codec[i].cmd != data; i++);
- if(codec[i].proc)
- codec[i].proc(codebuf);
-#ifdef _DEBUG
- else
- {
- char buf[256];
- wsprintf(buf,"Unknown Ansi code:'%c' (%s)\n",data,codebuf);
- OutputDebugString(buf);
- }
-#endif
- state = as_normal;
- }
- else
- codebuf[codeptr++] = data;
- break;
- }
-}
-
-/* EOF */
reactos/apps/utils/net/telnet
diff -N console.cpp
--- console.cpp 27 Jan 2001 22:38:43 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,43 +0,0 @@
-/* $Id: console.cpp,v 1.1 2001/01/27 22:38:43 ea Exp $
- *
- * FILE : console.cpp
- * AUTHOR : E.Aliberti
- * PROJECT : ReactOS Operating System
- * DESCRIPTION: telnet client for the W32 subsystem
- * DATE : 2001-01-21
- * REVISIONS
- * 2001-02-21 ea added to group console-related methods
- */
-#include <windows.h>
-
-const char * title = "telnet - ";
-
-// Set console's title
-void console_title_connecting (
- char const* pszHostName,
- const int nPort
- )
-{
- char t[256];
- wsprintf(t,"%sconnecting to %s:%i", title, pszHostName, nPort);
- SetConsoleTitle(t);
-}
-
-void console_title_connected (
- char const* pszHostName,
- const int nPort
- )
-{
- char t[256];
- wsprintf(t,"%sconnected to %s:%i", title, pszHostName, nPort);
- SetConsoleTitle(t);
-}
-
-void console_title_not_connected (void)
-{
- char t[256];
- wsprintf(t,"%snot connected", title);
- SetConsoleTitle(t);
-}
-
-/* EOF */
reactos/apps/utils/net/telnet
diff -N console.h
--- console.h 27 Jan 2001 22:38:43 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,12 +0,0 @@
-#ifndef _APPS_NET_TELNET_CONSOLE_H
-#define _APPS_NET_TELNET_CONSOLE_H
-void console_title_connecting (
- char const* pszHostName,
- const int nPort
- );
-void console_title_connected (
- char const* pszHostName,
- const int nPort
- );
-void console_title_not_connected (void);
-#endif /* _APPS_NET_TELNET_CONSOLE_H */
reactos/apps/utils/net/telnet
diff -N helpsock.cpp
--- helpsock.cpp 27 Jan 2001 22:38:43 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,40 +0,0 @@
-/* $Id: helpsock.cpp,v 1.1 2001/01/27 22:38:43 ea Exp $
- *
- * FILE : helpsock.cpp
- * AUTHOR : unknown (sources found on www.telnet.org)
- * PROJECT : ReactOS Operating System
- * DESCRIPTION: telnet client for the W32 subsystem
- * DATE : 2001-01-21
- * REVISIONS
- * 2001-02-21 ea Modified to compile under 0.0.16 src tree
- */
-#include <winsock.h>
-#include <windows.h>
-#include <process.h>
-
-#include "telnet.h"
-
-char const* sockmsg(int ecode)
-{
- switch(ecode)
- {
-// programming errors
-// (should never occour in release code?)
- case WSASYSNOTREADY: return "tcp/ip network not ready";
- case WSAEINVAL: return "invalid winsock version";
- case WSAVERNOTSUPPORTED: return "wrong winsock version";
- case WSANOTINITIALISED: return "winsock not initialized";
- case WSAEINTR: "The call was canceled";
- case WSAEINPROGRESS: "A blocking winsock operation is in progress";
- default: return "unknown winsock error";
-// general TCP problems
- case WSAENETDOWN: return "winsock has detected that the network subsystem has failed";
-// GetXbyY related errors:
- case WSAHOST_NOT_FOUND: return "Authoritative Answer Host not found";
- case WSATRY_AGAIN: return "Non-Authoritative Host not found, or SERVERFAIL";
- case WSANO_RECOVERY: "Nonrecoverable errors: FORMERR, REFUSED, NOTIMP";
- case WSANO_DATA: "Valid name, no data record of requested type";
- }
-}
-
-/* EOF */
reactos/apps/utils/net/telnet
diff -N main.cpp
--- main.cpp 27 Jan 2001 22:38:43 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,180 +0,0 @@
-/* $Id: main.cpp,v 1.1 2001/01/27 22:38:43 ea Exp $
- *
- * FILE : main.cpp
- * AUTHOR : unknown (sources found on www.telnet.org)
- * PROJECT : ReactOS Operating System
- * DESCRIPTION: telnet client for the W32 subsystem
- * DATE : 2001-01-21
- * REVISIONS
- * 2001-02-21 ea Modified to compile under 0.0.16 src tree
- * 2001-02-27 ea If run with no argument, it asks for a hostname.
- */
-///////////////////////////////////////////////////////////////////////////////
-//
-// File:
-// main.cpp
-//
-// Purpose:
-// This file provdes the main entry point for the project, and all the
-// global scope support routines.
-//
-// Notes:
-// This file expects to be linked without the C-Runtime. If compiling,
-// please force the entry point symbol to be "main", and do not link in
-// the default librarys.
-// This means that no c-runtime functions can be used anywhere in the
-// project. I expect this will also exclude any MFC based additions.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include <winsock.h>
-#include <windows.h>
-#include <process.h>
-#include <stdlib.h>
-
-#include "telnet.h"
-
-///////////////////////////////////////////////////////////////////////////////
-
-//
-// Our simple replacement for the c-runtime includes getting the StandardInput,
-// StandardOutput & StandardError handles, and providing new and delete operators, that work
-// with the win32 heap functions.
-//
-
-//
-// standard handles needed for CRT emulation
-//
-HANDLE hHeap;
-HANDLE StandardInput;
-HANDLE StandardOutput;
-HANDLE StandardError;
-
-//
-// new will use the win32 heap functions.
-//
-void* operator new(unsigned int nSize)
-{
- return HeapAlloc(hHeap,0,nSize);
-}
-
-//
-// delete operator provides all memory de-allocation.
-// HeapFree doesn't accept NULL.
-//
-void operator delete(void* pMem)
-{
- if(pMem) HeapFree(hHeap,0,pMem);
-}
-
-
-
-void err(char const* s, ...)
-{
- char buf [1024];
- DWORD nout;
-
- wvsprintf (buf, s, (char*)(s + sizeof(int)));
- WriteFile (StandardError,"Error: ", 7, & nout, NULL);
- WriteFile (StandardError, buf, lstrlen(buf), & nout, NULL);
- WriteFile (StandardError, "\r\n\r\n", 4, & nout, NULL);
-#ifdef _DEBUG
- OutputDebugString(buf);
- OutputDebugString("\n");
-#endif
- ExitProcess (ERROR_SUCCESS);
-}
-
-
-int main(int argc, char * argv[])
-{
- WSADATA wd;
- int errn;
- char name [256] = {'\0'};
- short port = IPPORT_TELNET; /* default tcp port */
-
- ///////////////////////////////////////
- // CRT emulation init
- // Get the IO handles
- StandardInput = GetStdHandle(STD_INPUT_HANDLE);
- StandardOutput = GetStdHandle(STD_OUTPUT_HANDLE);
- StandardError = GetStdHandle(STD_ERROR_HANDLE);
-
- // Get the heap
- hHeap = GetProcessHeap();
-
- // Explicitly force the console into a good mode (actually all we are doing is turning
- // mouse input off.
- SetConsoleMode (
- StandardInput,
- (ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT | ENABLE_PROCESSED_INPUT)
- );
-
- ///////////////////////////////////////
- // Init winsock
-
- if (errn = WSAStartup (0x0101, & wd))
- {
- err(sockmsg(errn));
- }
-
- /* hostname */
- if (1 < argc)
- {
- lstrcpy (name, argv [1]);
- }
- /*
- * Default port is IPPORT_TELNET.
- * User may hand one.
- */
- if (3 == argc)
- {
- port = atoi (argv[2]);
- if (port <= 0)
- {
- struct servent * service = NULL;
-
- service = getservbyname (argv[2], "tcp");
- if (NULL == service)
- {
- err("Invalid service name specified");
- }
- port = service->s_port;
- }
- else
- {
- err("Invalid port specified");
- }
- }
- /* Too many arguments */
- if (3 < argc)
- {
- err("Usage: telnet <hostname> [<port>]");
- }
- /* No argument */
- if (1 == argc)
- {
- DWORD Count;
- char *c;
-
- WriteFile (StandardError,"host: ", 6, & Count, NULL);
- ReadFile (StandardInput, name, sizeof name, & Count, NULL);
- c = name;
- while (*c > ' ') ++ c;
- *c = '\0';
- }
-
- // guess what this does.
- telnet (name, port);
-
- //Bye bye...
- WSACleanup ();
-
- // Exit process terminates any waiting threads.
- // (Its the CRT that makes a process close when the main thread exits.
- // The WinAPI will leave the process as is for as long as it has a
- // thread any thread.
- ExitProcess (EXIT_SUCCESS);
-}
-
-/* EOF */
reactos/apps/utils/net/telnet
diff -N nvt.cpp
--- nvt.cpp 27 Jan 2001 22:38:43 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,296 +0,0 @@
-/* $Id: nvt.cpp,v 1.1 2001/01/27 22:38:43 ea Exp $
- *
- * FILE : nvt.cpp
- * AUTHOR : unknown (sources found on www.telnet.org)
- * PROJECT : ReactOS Operating System
- * DESCRIPTION: telnet client for the W32 subsystem
- * DATE : 2001-01-21
- * REVISIONS
- * 2001-02-21 ea Modified to compile under 0.0.16 src tree
- */
-///////////////////////////////////////////////////////////////////////////////
-//
-// file: nvt.cpp
-//
-// purpose: Provides the "bare bones" telnet "Network Virtual Terminal"
-// that is our default. We only se a more capable terminal, if
-// properly requested via the telnet option.
-//
-// refrence: The following excerpt from rfc 854
-//
-///////////////////////////////////////////////////////////////////////////////
-/*
-THE NETWORK VIRTUAL TERMINAL
-
- The Network Virtual Terminal (NVT) is a bi-directional character
- device. The NVT has a printer and a keyboard. The printer responds
- to incoming data and the keyboard produces outgoing data which is
- sent over the TELNET connection and, if "echoes" are desired, to the
- NVT's printer as well. "Echoes" will not be expected to traverse the
- network (although options exist to enable a "remote" echoing mode of
- operation, no host is required to implement this option). The code
- set is seven-bit USASCII in an eight-bit field, except as modified
- herein. Any code conversion and timing considerations are local
- problems and do not affect the NVT.
-
- TRANSMISSION OF DATA
-
- Although a TELNET connection through the network is intrinsically
- full duplex, the NVT is to be viewed as a half-duplex device
- operating in a line-buffered mode. That is, unless and until
- options are negotiated to the contrary, the following default
- conditions pertain to the transmission of data over the TELNET
- connection:
-
- 1) Insofar as the availability of local buffer space permits,
- data should be accumulated in the host where it is generated
- until a complete line of data is ready for transmission, or
- until some locally-defined explicit signal to transmit occurs.
- This signal could be generated either by a process or by a
- human user.
-
- The motivation for this rule is the high cost, to some hosts,
- of processing network input interrupts, coupled with the
- default NVT specification that "echoes" do not traverse the
- network. Thus, it is reasonable to buffer some amount of data
- at its source. Many systems take some processing action at the
- end of each input line (even line printers or card punches
- frequently tend to work this way), so the transmission should
- be triggered at the end of a line. On the other hand, a user
- or process may sometimes find it necessary or desirable to
- provide data which does not terminate at the end of a line;
- therefore implementers are cautioned to provide methods of
- locally signaling that all buffered data should be transmitted
- immediately.
-
- 2) When a process has completed sending data to an NVT printer
- and has no queued input from the NVT keyboard for further
- processing (i.e., when a process at one end of a TELNET
- connection cannot proceed without input from the other end),
- the process must transmit the TELNET Go Ahead (GA) command.
-
- This rule is not intended to require that the TELNET GA command
- be sent from a terminal at the end of each line, since server
- hosts do not normally require a special signal (in addition to
- end-of-line or other locally-defined characters) in order to
- commence processing. Rather, the TELNET GA is designed to help
- a user's local host operate a physically half duplex terminal
- which has a "lockable" keyboard such as the IBM 2741. A
- description of this type of terminal may help to explain the
- proper use of the GA command.
-
- The terminal-computer connection is always under control of
- either the user or the computer. Neither can unilaterally
- seize control from the other; rather the controlling end must
- relinguish its control explicitly. At the terminal end, the
- hardware is constructed so as to relinquish control each time
- that a "line" is terminated (i.e., when the "New Line" key is
- typed by the user). When this occurs, the attached (local)
- computer processes the input data, decides if output should be
- generated, and if not returns control to the terminal. If
- output should be generated, control is retained by the computer
- until all output has been transmitted.
-
- The difficulties of using this type of terminal through the
- network should be obvious. The "local" computer is no longer
- able to decide whether to retain control after seeing an
- end-of-line signal or not; this decision can only be made by
- the "remote" computer which is processing the data. Therefore,
- the TELNET GA command provides a mechanism whereby the "remote"
- (server) computer can signal the "local" (user) computer that
- it is time to pass control to the user of the terminal. It
- should be transmitted at those times, and only at those times,
- when the user should be given control of the terminal. Note
- that premature transmission of the GA command may result in the
- blocking of output, since the user is likely to assume that the
- transmitting system has paused, and therefore he will fail to
- turn the line around manually.
-
- The foregoing, of course, does not apply to the user-to-server
- direction of communication. In this direction, GAs may be sent at
- any time, but need not ever be sent. Also, if the TELNET
- connection is being used for process-to-process communication, GAs
- need not be sent in either direction. Finally, for
- terminal-to-terminal communication, GAs may be required in
- neither, one, or both directions. If a host plans to support
- terminal-to-terminal communication it is suggested that the host
- provide the user with a means of manually signaling that it is
- time for a GA to be sent over the TELNET connection; this,
- however, is not a requirement on the implementer of a TELNET
- process.
-
- Note that the symmetry of the TELNET model requires that there is
- an NVT at each end of the TELNET connection, at least
- conceptually.
-*//*
-
- THE NVT PRINTER AND KEYBOARD
-
- The NVT printer has an unspecified carriage width and page length
- and can produce representations of all 95 USASCII graphics (codes
- 32 through 126). Of the 33 USASCII control codes (0 through 31
- and 127), and the 128 uncovered codes (128 through 255), the
- following have specified meaning to the NVT printer:
-
- NAME CODE MEANING
-
- NULL (NUL) 0 No Operation
- Line Feed (LF) 10 Moves the printer to the
- next print line, keeping the
- same horizontal position.
- Carriage Return (CR) 13 Moves the printer to the left
- margin of the current line.
-
- In addition, the following codes shall have defined, but not
- required, effects on the NVT printer. Neither end of a TELNET
- connection may assume that the other party will take, or will
- have taken, any particular action upon receipt or transmission
- of these:
-
- BELL (BEL) 7 Produces an audible or
- visible signal (which does
- NOT move the print head).
- Back Space (BS) 8 Moves the print head one
- character position towards
- the left margin.
- Horizontal Tab (HT) 9 Moves the printer to the
- next horizontal tab stop.
- It remains unspecified how
- either party determines or
- establishes where such tab
- stops are located.
- Vertical Tab (VT) 11 Moves the printer to the
- next vertical tab stop. It
- remains unspecified how
- either party determines or
- establishes where such tab
- stops are located.
- Form Feed (FF) 12 Moves the printer to the top
- of the next page, keeping
- the same horizontal position.
-
- All remaining codes do not cause the NVT printer to take any
- action.
-
- The sequence "CR LF", as defined, will cause the NVT to be
- positioned at the left margin of the next print line (as would,
- for example, the sequence "LF CR"). However, many systems and
- terminals do not treat CR and LF independently, and will have to
- go to some effort to simulate their effect. (For example, some
- terminals do not have a CR independent of the LF, but on such
- terminals it may be possible to simulate a CR by backspacing.)
- Therefore, the sequence "CR LF" must be treated as a single "new
- line" character and used whenever their combined action is
- intended; the sequence "CR NUL" must be used where a carriage
- return alone is actually desired; and the CR character must be
- avoided in other contexts. This rule gives assurance to systems
- which must decide whether to perform a "new line" function or a
- multiple-backspace that the TELNET stream contains a character
- following a CR that will allow a rational decision.
-
- Note that "CR LF" or "CR NUL" is required in both directions
- (in the default ASCII mode), to preserve the symmetry of the
- NVT model. Even though it may be known in some situations
- (e.g., with remote echo and suppress go ahead options in
- effect) that characters are not being sent to an actual
- printer, nonetheless, for the sake of consistency, the protocol
- requires that a NUL be inserted following a CR not followed by
- a LF in the data stream. The converse of this is that a NUL
- received in the data stream after a CR (in the absence of
- options negotiations which explicitly specify otherwise) should
- be stripped out prior to applying the NVT to local character
- set mapping.
-
- The NVT keyboard has keys, or key combinations, or key sequences,
- for generating all 128 USASCII codes. Note that although many
- have no effect on the NVT printer, the NVT keyboard is capable of
- generating them.
-
- In addition to these codes, the NVT keyboard shall be capable of
- generating the following additional codes which, except as noted,
- have defined, but not reguired, meanings. The actual code
- assignments for these "characters" are in the TELNET Command
- section, because they are viewed as being, in some sense, generic
- and should be available even when the data stream is interpreted
- as being some other character set.
-
- Synch
-
- This key allows the user to clear his data path to the other
- party. The activation of this key causes a DM (see command
- section) to be sent in the data stream and a TCP Urgent
- notification is associated with it. The pair DM-Urgent is to
- have required meaning as defined previously.
-
- Break (BRK)
-
- This code is provided because it is a signal outside the
- USASCII set which is currently given local meaning within many
- systems. It is intended to indicate that the Break Key or the
- Attention Key was hit. Note, however, that this is intended to
- provide a 129th code for systems which require it, not as a
- synonym for the IP standard representation.
-
- Interrupt Process (IP)
-
- Suspend, interrupt, abort or terminate the process to which the
- NVT is connected. Also, part of the out-of-band signal for
- other protocols which use TELNET.
-
- Abort Output (AO)
-
- Allow the current process to (appear to) run to completion, but
- do not send its output to the user. Also, send a Synch to the
- user.
-
- Are You There (AYT)
-
- Send back to the NVT some visible (i.e., printable) evidence
- that the AYT was received.
-
- Erase Character (EC)
-
- The recipient should delete the last preceding undeleted
- character or "print position" from the data stream.
-
- Erase Line (EL)
-
- The recipient should delete characters from the data stream
- back to, but not including, the last "CR LF" sequence sent over
- the TELNET connection.
-
- The spirit of these "extra" keys, and also the printer format
- effectors, is that they should represent a natural extension of
- the mapping that already must be done from "NVT" into "local".
- Just as the NVT data byte 68 (104 octal) should be mapped into
- whatever the local code for "uppercase D" is, so the EC character
- should be mapped into whatever the local "Erase Character"
- function is. Further, just as the mapping for 124 (174 octal) is
- somewhat arbitrary in an environment that has no "vertical bar"
- character, the EL character may have a somewhat arbitrary mapping
- (or none at all) if there is no local "Erase Line" facility.
- Similarly for format effectors: if the terminal actually does
- have a "Vertical Tab", then the mapping for VT is obvious, and
- only when the terminal does not have a vertical tab should the
-
-*/
-
-#include <winsock.h>
-#include <windows.h>
-
-#include "telnet.h"
-
-void nvt(SOCKET server,unsigned char data)
-{
- DWORD z;
- switch(data)
- {
- case 0: //eat null codes.
- break;
- default: //Send all else to the console.
- WriteConsole(StandardOutput, & data, 1, & z, NULL);
- break;
- }
-}
-
-/* EOF */
reactos/apps/utils/net/telnet
diff -N telnet.cpp
--- telnet.cpp 27 Jan 2001 22:38:43 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,130 +0,0 @@
-/* $Id: telnet.cpp,v 1.1 2001/01/27 22:38:43 ea Exp $
- *
- * FILE : telnet.cpp
- * AUTHOR : unknown (sources found on www.telnet.org)
- * PROJECT : ReactOS Operating System
- * DESCRIPTION: telnet client for the W32 subsystem
- * DATE : 2001-01-21
- * REVISIONS
- * 2001-02-21 ea Modified to compile under 0.0.16 src tree
- */
-#include <winsock.h>
-#include <windows.h>
-
-#include "telnet.h"
-#include "console.h"
-
-
-//
-// sock_loop is the thread dedicatd to reading socket input.
-// It waits for data from the socket, and then gives it one byte at a time
-// to the telnet vm to process.
-//
-
-DWORD sock_loop(SOCKET server)
-{
- char buf[256];
- unsigned long read;
- char* scan;
-
- while( (read = recv(server,buf,sizeof(buf),0)) && read != SOCKET_ERROR )
- {
- scan = buf;
- while(read--)
- vm(server,*scan++);
- }
- int x = WSAGetLastError();
- return 0;
-}
-
-DWORD input_loop(SOCKET server)
-{
- char buf[256];
- DWORD read;
-
- do
- {
- WaitForSingleObject(StandardInput, INFINITE);
- ReadFile(StandardInput, buf, sizeof buf, & read, NULL);
- }
- while(SOCKET_ERROR != send(server, buf, read, 0));
-
- return 0;
-
-}
-
-void telnet(SOCKET server)
-{
- DWORD dwThreadIdsock;
- DWORD dwThreadIdinput;
- HANDLE threads[2];
-
-
- threads[0] = CreateThread(
- NULL, /* no security attributes */
- 0, /* use default stack size */
- (LPTHREAD_START_ROUTINE) sock_loop, /* thread function */
- (LPVOID)server, /* argument to thread function */
- 0, /* use default creation flags */
- &dwThreadIdsock); /* returns the thread identifier */
-
- //wait for the other thread to complete any setup negotiation...
- //Sleep(500); //- this is not the problem - its just bloody stuffing up!
-
- threads[1] = CreateThread(
- NULL, /* no security attributes */
- 0, /* use default stack size */
- (LPTHREAD_START_ROUTINE) input_loop, /* thread function */
- (LPVOID)server, /* argument to thread function */
- 0, /* use default creation flags */
- &dwThreadIdinput); /* returns the thread identifier */
-
-
- WaitForMultipleObjects(2,threads,FALSE,INFINITE);
-}
-
-
-//
-// connect to the hostname,port
-//
-void telnet(
- char const* pszHostName,
- const short nPort)
-{
- unsigned long ip;
- if((*pszHostName <= '9') && (*pszHostName >= '0'))
- {
- if((ip = inet_addr(pszHostName)) == INADDR_NONE)
- err("invalid host IP address given");
- }
- else
- {
- hostent* ent = gethostbyname(pszHostName);
- if(!ent)
- err(sockmsg(WSAGetLastError()));
- ip = *(unsigned long*)(ent->h_addr);
- }
-
- sockaddr_in name;
- name.sin_family = AF_INET;
- name.sin_port = htons(nPort);
- name.sin_addr = *(in_addr*)&ip;
-
- console_title_connecting (pszHostName, nPort);
-
- SOCKET server;
-
- if((server = socket(PF_INET,SOCK_STREAM,IPPROTO_TCP))==INVALID_SOCKET)
- err(sockmsg(WSAGetLastError()));
-
- if(SOCKET_ERROR == connect(server,(sockaddr*)&name,sizeof(sockaddr)))
- err(sockmsg(WSAGetLastError()));
-
- console_title_connected (pszHostName, nPort);
-
- telnet(server);
-
- closesocket(server);
-}
-
-/* EOF */
reactos/apps/utils/net/telnet
diff -N telnet.h
--- telnet.h 27 Jan 2001 22:38:43 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,24 +0,0 @@
-#ifndef _APPS_NET_TELNET_H
-#define _APPS_NET_TELNET_H
-//Global Handles
-extern HANDLE StandardInput;
-extern HANDLE StandardOutput;
-extern HANDLE StandardError;
-
-extern char const* sockmsg(int ecode);
-extern void err(char const* s,...);
-
-extern void telnet(char const* pszHostName,const short nPort);
-extern void vm(SOCKET,unsigned char);
-
-// terminal handlers:
-void ansi(SOCKET server,unsigned char data);
-void nvt(SOCKET server,unsigned char data);
-
-// helpsock
-char const* sockmsg(int ecode);
-
-// command shell
-int shell(char const* pszHostName,const int nPort);
-
-#endif /* ndef _APPS_NET_TELNET_H */
reactos/apps/utils/net/telnet
diff -N vm.cpp
--- vm.cpp 27 Jan 2001 22:38:43 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,424 +0,0 @@
-/* $Id: vm.cpp,v 1.1 2001/01/27 22:38:43 ea Exp $
- *
- * FILE : vm.cpp
- * AUTHOR : unknown (sources found on www.telnet.org)
- * PROJECT : ReactOS Operating System
- * DESCRIPTION: telnet client for the W32 subsystem
- * DATE : 2001-01-21
- * REVISIONS
- * 2001-02-21 ea Modified to compile under 0.0.16 src tree
- */
-#include <winsock.h>
-#include <windows.h>
-
-#include "telnet.h"
-
-// NAME CODE MEANING
-// NVT codes
-#define NUL 0 // No Operation
-#define BEL 7 // BELL
-#define BS 8 // Back Space
-#define HT 9 // Horizontal Tab
-#define LF 10 // Line Feed
-#define VT 11 // Vertical Tab
-#define FF 12 // Form Feed
-#define CR 13 // Carriage Return
-
-// telnet command codes
-#define SE 240 // End of subnegotiation parameters.
-#define NOP 241 // No operation.
-#define DM 242 // Data Mark
-#define BRK 243 // Break
-#define IP 244 // Interrupt Process
-#define AO 245 // Abort output
-#define AYT 246 // Are You There
-#define EC 247 // Erase character
-#define EL 248 // Erase Line
-#define GA 249 // Go ahead
-#define SB 250 // SuBnegotiate
-#define WILL 251 //
-#define WONT 252 //
-#define DO 253 //
-#define DONT 254 //
-#define IAC 255 // Interpret As Command
-
-//Telnet options:
-// 0x00 - binary mode
-// 0x01 - Local Echo
-// 0x03 - Suppress GA (char at a time)
-// 0x05 - status
-// 0x06 - Timing Mark
-//
-// do 0x25 - zub?
-//
-// 0xff - Extended Options List
-
-enum _option
-{
- TOPT_BIN = 0, // Binary Transmission
- TOPT_ECHO = 1, // Echo
- TOPT_RECN = 2, // Reconnection
- TOPT_SUPP = 3, // Suppress Go Ahead
- TOPT_APRX = 4, // Approx Message Size Negotiation
- TOPT_STAT = 5, // Status
- TOPT_TIM = 6, // Timing Mark
- TOPT_REM = 7, // Remote Controlled Trans and Echo
- TOPT_OLW = 8, // Output Line Width
- TOPT_OPS = 9, // Output Page Size
- TOPT_OCRD = 10, // Output Carriage-Return Disposition
- TOPT_OHT = 11, // Output Horizontal Tabstops
- TOPT_OHTD = 12, // Output Horizontal Tab Disposition
- TOPT_OFD = 13, // Output Formfeed Disposition
- TOPT_OVT = 14, // Output Vertical Tabstops
- TOPT_OVTD = 15, // Output Vertical Tab Disposition
- TOPT_OLD = 16, // Output Linefeed Disposition
- TOPT_EXT = 17, // Extended ASCII
- TOPT_LOGO = 18, // Logout
- TOPT_BYTE = 19, // Byte Macro
- TOPT_DATA = 20, // Data Entry Terminal
- TOPT_SUP = 21, // SUPDUP
- TOPT_SUPO = 22, // SUPDUP Output
- TOPT_SNDL = 23, // Send Location
- TOPT_TERM = 24, // Terminal Type
- TOPT_EOR = 25, // End of Record
- TOPT_TACACS = 26, // TACACS User Identification
- TOPT_OM = 27, // Output Marking
- TOPT_TLN = 28, // Terminal Location Number
- TOPT_3270 = 29, // Telnet 3270 Regime
- TOPT_X3 = 30, // X.3 PAD
- TOPT_NAWS = 31, // Negotiate About Window Size
- TOPT_TS = 32, // Terminal Speed
- TOPT_RFC = 33, // Remote Flow Control
- TOPT_LINE = 34, // Linemode
- TOPT_XDL = 35, // X Display Location
- TOPT_ENVIR = 36,// Telnet Environment Option
- TOPT_AUTH = 37, // Telnet Authentication Option
- TOPT_NENVIR = 39,// Telnet Environment Option
- TOPT_EXTOP = 255, // Extended-Options-List
- TOPT_ERROR = 256 // Magic number
-};
-
-// Wanted by linux box:
-// 37 - TOPT_AUTH
-// 24 - TOPT_TERM
-
-enum _verb
-{
- verb_sb = 250,
- verb_will = 251,
- verb_wont = 252,
- verb_do = 253,
- verb_dont = 254
-};
-
-enum _state
-{
- state_data, //we expect a data byte
- state_code, //we expect a code
- state_option //we expect an option
-};
-
-int option_error(_verb,_option,int,SOCKET);
-
-typedef void(*LPOPTIONPROC)(SOCKET,_verb,_option);
-typedef void(*LPDATAPROC)(SOCKET,unsigned char data);
-
-///////////////////////////////////////////////////////////////////////////////
-
-inline void yesreply(SOCKET server, _verb verb,_option option)
-{
- unsigned char buf[3];
- buf[0] = IAC;
- buf[1] = (verb==verb_do)?WILL:(verb==verb_dont)?WONT:(verb==verb_will)?DO:DONT;
- buf[2] = (unsigned char)option;
- send(server,(char*)buf,3,0);
-}
-
-inline void noreply(SOCKET server, _verb verb,_option option)
-{
- unsigned char buf[3];
- buf[0] = IAC;
- buf[1] = (verb==verb_do)?WONT:(verb==verb_dont)?WILL:(verb==verb_will)?DONT:DO;
- buf[2] = (unsigned char)option;
- send(server,(char*)buf,3,0);
-}
-
-inline void askfor(SOCKET server, _verb verb,_option option)
-{
- unsigned char buf[3];
- buf[0] = IAC;
- buf[1] = (unsigned char)verb;
- buf[2] = (unsigned char)option;
- send(server,(char*)buf,3,0);
-}
-
-
-void ddww_error(SOCKET server,_verb verb,_option option)
-{
-#ifdef _DEBUG
- char tmp[256];
- wsprintf(tmp,"Unknown Option Code: %s, %i\n",(verb==verb_do)?"DO":(verb==verb_dont)?"DON'T":(verb==verb_will)?"WILL":"WONT",(int)option);
- OutputDebugString(tmp);
-#endif
-
- switch(verb)
- {
- case verb_will: // server wants to support something
- noreply(server,verb,option); // I don't want that.
- break;
- case verb_wont: // server waants to disable support
- return; // don't confirm - already disabled.
- case verb_do: // server wants me to support something
- noreply(server,verb,option); //I won't do that
- break;
- case verb_dont: // server wants me to disable something
- return; // don't worry, we don't do that anyway (I hope :)
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Option ECHO & SUPPRESS GA
-//
-// These options are curiously intertwined...
-// The Win32 console doesn't support ECHO_INPUT (echo) if
-// LINE_INPUT (==GA) isn't set.
-// I can't see how to code this negotiation without using
-// some form of Lock-Step algorythm
-// ie: if("WILL ECHO")
-// Send "DO SUPP"
-// if("WILL SUPP")
-// Send "DO ECHO"
-// else
-// Send "DONT ECHO"
-
-
-void ddww_echo(SOCKET server,_verb verb, _option option)
-{
- DWORD mode;
- GetConsoleMode(StandardInput, & mode); // ENABLE_ECHO_INPUT
-
- int set = !(mode & ENABLE_ECHO_INPUT);
-
- switch(verb)
- {
- case verb_will: // server wants to echo stuff
- if(set) return; //don't confirm - already set.
- SetConsoleMode(StandardInput,mode & (~ENABLE_ECHO_INPUT));
- break;
- case verb_wont: // server don't want to echo
- if(!set) return; //don't confirm - already unset.
- SetConsoleMode(StandardInput,mode | ENABLE_ECHO_INPUT);
- break;
- case verb_do: // server wants me to loopback
- noreply(server,verb,option);
- return;
- case verb_dont: // server doesn't want me to echo
- break; // don't bother to reply - I don't
- }
- yesreply(server,verb,option);
-}
-
-
-void ddww_supp(SOCKET server,_verb verb,_option option) //Suppress GA
-{
- DWORD mode;
- GetConsoleMode(StandardInput,&mode); // ENABLE_LINE_INPUT
-
- int set = !(mode & ENABLE_LINE_INPUT);
-
- switch(verb)
- {
- case verb_will: // server wants to suppress GA's
- if(set) break; //don't confirm - already set.
- SetConsoleMode(StandardInput,mode & (~(ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT)));
- askfor(server,verb_do,TOPT_SUPP);
- askfor(server,verb_will,TOPT_SUPP);
- askfor(server,verb_do,TOPT_ECHO);
- break;
- case verb_wont: // server wants to send GA's
- if(!set) break; //don't confirm - already unset.
- SetConsoleMode(StandardInput,mode | ENABLE_LINE_INPUT);
- askfor(server,verb_dont,TOPT_SUPP);
- askfor(server,verb_wont,TOPT_SUPP);
- break;
- case verb_do: // server wants me to suppress GA's
- if(set) break;
- askfor(server,verb_do,TOPT_SUPP);
- break;
- case verb_dont: // server wants me to send GA's
- if(!set) break;
- askfor(server,verb_dont,TOPT_SUPP);
- break;
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Option TERMINAL-TYPE
-
-void ddww_term(SOCKET server,_verb verb,_option option) //Subnegotiate terminal type
-{
- switch(verb)
- {
- case verb_will:
- noreply(server,verb,option); // I don't want terminal info
- break;
- case verb_wont:
- //dat be cool - its not going to send. no need to confirm
- break;
- case verb_do:
- yesreply(server,verb,option); //I'll send it when asked
- break;
- case verb_dont://Ok - I won't
- break;
- }
-}
-
-// TERMINAL TYPE subnegotation
-enum
-{
- SB_TERM_IS = 0,
- SB_TERM_SEND = 1
-};
-
-#define NUM_TERMINALS 2
-
-struct
-{
- char* name;
- LPDATAPROC termproc;
- //pre requsites.
-} terminal[NUM_TERMINALS] = {
- { "NVT", nvt },
- { "ANSI", ansi }
-};
-
-int term_index = 0;
-
-void sbproc_term(SOCKET server,unsigned char data)
-{
-
- if(data == SB_TERM_SEND)
- {
- if(term_index == NUM_TERMINALS)
- term_index = 0;
- else
- term_index++;
- char buf[16]; //pls limit
- buf[0] = IAC;
- buf[1] = SB;
- buf[2] = TOPT_TERM;
- buf[3] = SB_TERM_IS;
- lstrcpy(&buf[4],terminal[(term_index==NUM_TERMINALS)?(NUM_TERMINALS-1):term_index].name);
- int nlen = lstrlen(&buf[4]);
- buf[4+nlen] = IAC;
- buf[5+nlen] = SE;
- send(server,buf,4+nlen+2,0);
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-struct
-{
- _option option;
- LPOPTIONPROC OptionProc;
- LPDATAPROC DataProc;
-} ol[] = {
- {TOPT_ECHO, ddww_echo, NULL},
- {TOPT_SUPP, ddww_supp, NULL},
- {TOPT_TERM, ddww_term, sbproc_term},
- {TOPT_ERROR, ddww_error, NULL}
-};
-
-
-void vm(SOCKET server,unsigned char code)
-{
-//These vars are the finite state
- static int state = state_data;
- static _verb verb = verb_sb;
- static LPDATAPROC DataProc = terminal[(term_index==NUM_TERMINALS)?(NUM_TERMINALS-1):term_index].termproc;
-// for index
- int i=0;
-
-//Decide what to do (state based)
- switch(state)
- {
- case state_data:
- switch(code)
- {
- case IAC: state = state_code; break;
- default: DataProc(server,code);
- }
- break;
- case state_code:
- state = state_data;
- switch(code)
- {
- // State transition back to data
- case IAC:
- DataProc(server,code);
- break;
- // Code state transitions back to data
- case SE:
- DataProc = terminal[(term_index==NUM_TERMINALS)?(NUM_TERMINALS-1):term_index].termproc;
- break;
- case NOP:
- break;
- case DM:
- break;
- case BRK:
- break;
- case IP:
- break;
- case AO:
- break;
- case AYT:
- break;
- case EC:
- break;
- case EL:
- break;
- case GA:
- break;
- // Transitions to option state
- case SB:
- verb = verb_sb;
- state = state_option;
- break;
- case WILL:
- verb = verb_will;
- state = state_option;
- break;
- case WONT:
- verb = verb_wont;
- state = state_option;
- break;
- case DO:
- verb = verb_do;
- state = state_option;
- break;
- case DONT:
- verb = verb_dont;
- state = state_option;
- break;
- }
- break;
- case state_option:
- state = state_data;
-
- //Find the option entry
- for(
- i = 0;
- ol[i].option != TOPT_ERROR && ol[i].option != code;
- i++);
-
- //Do some verb specific stuff
- if(verb == verb_sb)
- DataProc = ol[i].DataProc;
- else
- ol[i].OptionProc(server,verb,(_option)code);
- break;
- }
-}
-
-/* EOF */
reactos/apps/utils/net/telnet/doc
diff -N 00readme.avs
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ 00readme.avs 21 Nov 2004 22:24:55 -0000 1.1
@@ -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.
+
+
reactos/apps/utils/net/telnet/doc
diff -N bugs.txt
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ bugs.txt 21 Nov 2004 22:24:55 -0000 1.1
@@ -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".
reactos/apps/utils/net/telnet/doc
diff -N changes.txt
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ changes.txt 21 Nov 2004 22:24:55 -0000 1.1
@@ -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
reactos/apps/utils/net/telnet/doc
diff -N license.txt
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ license.txt 21 Nov 2004 22:24:55 -0000 1.1
@@ -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.
+
reactos/apps/utils/net/telnet/doc
diff -N options.txt
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ options.txt 21 Nov 2004 22:24:55 -0000 1.1
@@ -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.
reactos/apps/utils/net/telnet/doc
diff -N readme.txt
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ readme.txt 21 Nov 2004 22:24:55 -0000 1.1
@@ -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>
reactos/apps/utils/net/telnet/doc
diff -N ssh.txt
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ssh.txt 21 Nov 2004 22:24:55 -0000 1.1
@@ -0,0 +1,22 @@
+It should be possible to add ssh support to console telnet, as console telnet has a very modular design when it comes to the networking code. There is already support for pipes, and if there exists an ssh client for Win32 that will output to stdout, then you're in business. I'm yet to find such a client, but if one existed, an SSH session could be started like so:
+
+C:\> telnet
+Copyright message, license.txt, stuff, etc.
+telnet> set io_netpipe "C:\BIN\SSH.EXE -l username host"
+telnet> open blah
+login:
+password:
+
+Unfortunately, all the ssh clients I've found don't work this way. You can output CMD.EXE to telnet this way, though, and get a very pretty ansi interpreter. If you want to try to get OpenSSH working, here's step-by-step instructions to get you started (please read them all the way though):
+
+1) Get Perl from http://www.activestate.com/ActivePerl/download.htm
+2) Get Openssl from http://www.openssl.org/source/
+ - Follow directions in INSTALL.W32
+ - Copy the .LIB files from OUT32DLL to your LIB directory (C:\DevStudio\VC\LIB)
+ - Copy the .DLL files from OUT32DLLto your system directory (C:\Winnt\System32 or C:\Windows\System)
+ - Copy the .H files from INC32\OPENSSL to your include\ssl (C:\DevStudio\VC\include\ssl)
+ - Copy these same files to include\openssl (C:\DevStudio\VC\include\openssl)
+3) Get Openssh from http://www.openssh.com
+4) Modify Openssh so it will compile, and get rid of all the termios stuff
+
+Obviously this is a lot of work. If you need a good ssh client, try PuTTY from http://www.chiark.greenend.org.uk/~sgtatham/putty/. It may be possible to integrate PuTTY and Telnet, and that would certainly be easier than the above option. PuTTY is licensed under the MIT license, which seems to be compatible with the GPL. The primary advantage of integrating the two projects is that PuTTY would gain the key mappings that telnet has, and telnet would gain encryption.
\ No newline at end of file
reactos/apps/utils/net/telnet/resource
diff -N tnmsg.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tnmsg.h 21 Nov 2004 22:24:55 -0000 1.1
@@ -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
reactos/apps/utils/net/telnet/resource
diff -N tnmsg.rc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tnmsg.rc 21 Nov 2004 22:24:55 -0000 1.1
@@ -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
reactos/apps/utils/net/telnet/src
diff -N .cvsignore
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ .cvsignore 21 Nov 2004 22:24:55 -0000 1.1
@@ -0,0 +1,17 @@
+*.sys
+*.exe
+*.dll
+*.cpl
+*.a
+*.o
+*.d
+*.coff
+*.dsp
+*.dsw
+*.aps
+*.ncb
+*.opt
+*.sym
+*.plg
+*.bak
+*.map
reactos/apps/utils/net/telnet/src
diff -N ansiprsr.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ansiprsr.cpp 21 Nov 2004 22:24:56 -0000 1.1
@@ -0,0 +1,1474 @@
+///////////////////////////////////////////////////////////////////////////////
+//Telnet Win32 : an ANSI telnet client.
+//Copyright (C) 1998-2000 Paul Brannan
+//Copyright (C) 1998 I.Ioannou
+//Copyright (C) 1997 Brad Johnson
+//
+//This program is free software; you can redistribute it and/or
+//modify it under the terms of the GNU General Public License
+//as published by the Free Software Foundation; either version 2
+//of the License, or (at your option) any later version.
+//
+//This program is distributed in the hope that it will be useful,
+//but WITHOUT ANY WARRANTY; without even the implied warranty of
+//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+//GNU General Public License for more details.
+//
+//You should have received a copy of the GNU General Public License
+//along with this program; if not, write to the Free Software
+//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+//I.Ioannou
+//roryt@hol.gr
+//
+///////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Module: ansiprsr.cpp
+//
+// Contents: ANSI parser base class
+//
+// Product: telnet
+//
+// Revisions: August 30, 1998 Paul Brannan <pbranna@clemson.edu>
+// July 29, 1998 pbranna@clemson.edu
+// June 15, 1998 pbranna@clemson.edu
+// May 19, 1998 pbranna@clemson.edu
+// 24 Dec, 1997 Andrey.V.Smilianets
+// 05. Sep.1997 roryt@hol.gr (I.Ioannou)
+// 11.May.1997 roryt@hol.gr (I.Ioannou)
+// 6.April.1997 roryt@hol.gr (I.Ioannou)
+// 5.April.1997 jbj@nounname.com
+// 30.M�rz.1997 Titus_Boxberg@public.uni-hamburg.de
+// 14.Sept.1996 jbj@nounname.com
+// Version 2.0
+//
+// 13.Jul.1995 igor.milavec@uni-lj.si
+// Original code
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#include <windows.h>
+#include <string.h>
+#include "ansiprsr.h"
+
+// The constructor now takes different arguments and initializes different
+// variables (Paul Brannan 6/15/98)
+TANSIParser::TANSIParser(TConsole &RefConsole, KeyTranslator &RefKeyTrans,
+ TScroller &RefScroller, TNetwork &RefNetwork,
+ TCharmap &RefCharmap):
+TParser(RefConsole, RefKeyTrans, RefScroller, RefNetwork, RefCharmap) {
+ Init();
+ iSavedAttributes = (unsigned char) 7;
+ // must also check to make sure the string is non-NULL
+ // (Paul Brannan 5/8/98)
+ if ((ini.get_dumpfile() != NULL) && (*ini.get_dumpfile() != '\0')){
+ dumpfile = fopen(ini.get_dumpfile(), "wb");
+ }else {
+ dumpfile = NULL;
+ }
+ InPrintMode = 0;
+ printfile = NULL;
+
+ fast_write = ini.get_fast_write(); // Paul Brannan 6/28/98
+ Scroller.init(&StripBuffer);
+}
+
+TANSIParser::~TANSIParser(){
+ if (dumpfile) fclose (dumpfile);
+ // Added I.Ioannou 06 April, 1997
+ if (printfile != NULL) fclose (printfile);
+}
+
+// Created Init() function to initialize the parser but not clear the screen
+// (Paul Brannan 9/23/98)
+void TANSIParser::Init() {
+ // Paul Brannan 6/25/98
+ map_G0 = 'B'; map_G1 = 'B';
+ Charmap.setmap(map_G0);
+ current_map = 'B';
+
+ ignore_margins = 0;
+ vt52_mode = 0;
+ print_ctrl = 0;
+ newline_mode = false;
+
+ KeyTrans.clear_ext_mode();
+
+ iSavedCurY = 0; // Reset Variables
+ iSavedCurX = 0;
+ inGraphMode = 0;
+ Console.SetScroll(-1, -1);
+ Console.Normal(); // Reset Attributes
+
+ // Set tabs stops
+ resetTabStops();
+}
+
+void TANSIParser::ResetTerminal() {
+ Init();
+ Console.ClearScreen(); // Clear Screen
+ Console.SetRawCursorPosition(0,0); // Home Cursor
+}
+void TANSIParser::SaveCurY(int iY){
+ iSavedCurY=iY;
+}
+
+void TANSIParser::SaveCurX(int iX){
+ iSavedCurX=iX;
+}
+
+void TANSIParser::resetTabStops() {
+ for(int j = 0; j < MAX_TAB_POSITIONS; j++) {
+ tab_stops[j] = 8 + j - (j%8);
+ }
+}
+
+void TANSIParser::ConSetAttribute(unsigned char TextAttrib){
+ // Paul Brannan 5/8/98
+ // Made this go a little bit faster by changing from switch{} to an array
+ // for the colors
+ if(TextAttrib >= 30) {
+ if(TextAttrib <= 37) {
+ Console.SetForeground(ANSIColors[TextAttrib-30]);
+ return;
+ } else if((TextAttrib >= 40) && (TextAttrib <= 47)) {
+ Console.SetBackground(ANSIColors[TextAttrib-40]);
+ return;
+ }
+ }
+
+ switch (TextAttrib){
+ // Text Attributes
+ case 0: Console.Normal(); break; // Normal video
+ case 1: Console.HighVideo(); break; // High video
+ case 2: Console.LowVideo(); break; // Low video
+ case 4: Console.UnderlineOn(); break; // Underline on (I.Ioannou)
+ case 5: Console.BlinkOn(); break; // Blink video
+ // Corrected by I.Ioannou 11 May, 1997
+ case 7: Console.ReverseOn(); break; // Reverse video
+ case 8: break; // hidden
+ // All from 10 thru 27 are hacked from linux kernel
+ // I.Ioannou 06 April, 1997
+ case 10:
+ // I.Ioannou 04 Sep 1997 turn on/off high bit
+ inGraphMode = 0;
+ print_ctrl = 0;
+ Charmap.setmap(current_map ? map_G1:map_G0); // Paul Brannan 6/25/98
+ break; // ANSI X3.64-1979 (SCO-ish?)
+ // Select primary font,
+ // don't display control chars
+ // if defined, don't set
+ // bit 8 on output (normal)
+ case 11:
+ inGraphMode = 0;
+ print_ctrl = 1;
+ Charmap.setmap(0); // Paul Brannan 6/25/98
+ break; // ANSI X3.64-1979 (SCO-ish?)
+ // Select first alternate font,
+ // let chars < 32 be displayed
+ // as ROM chars
+ case 12:
+ inGraphMode = 1;
+ print_ctrl = 1;
+ Charmap.setmap(0); // Paul Brannan 6/25/98
+ break; // ANSI X3.64-1979 (SCO-ish?)
+ // Select second alternate font,
+ // toggle high bit before
+ // displaying as ROM char.
+
+ case 21: // not really Low video
+ case 22: Console.LowVideo(); break; // but this works good also
+ case 24: Console.UnderlineOff(); break; // Underline off
+ case 25: Console.BlinkOff(); break; // blink off
+ // Corrected by I.Ioannou 11 May, 1997
+ case 27: Console.ReverseOff(); break; //Reverse video off
+
+ // Mutt needs this (Paul Brannan, Peter Jordan 12/31/98)
+ // This is from the Linux kernel source
+ case 38: /* ANSI X3.64-1979 (SCO-ish?)
+ * Enables underscore, white foreground
+ * with white underscore (Linux - use
+ * default foreground).
+ */
+ Console.UnderlineOn();
+ Console.SetForeground(ini.get_normal_fg());
+ break;
+ case 39: /* ANSI X3.64-1979 (SCO-ish?)
+ * Disable underline option.
+ * Reset colour to default? It did this
+ * before...
+ */
+ Console.UnderlineOff();
+ Console.SetForeground(ini.get_normal_fg());
+ break;
+ case 49:
+ Console.SetBackground(ini.get_normal_bg());
+ break;
+
+ }
+}
+
+void TANSIParser::ConSetCursorPos(int x, int y) {
+ if(ignore_margins)
+ Console.SetRawCursorPosition(x, y);
+ else
+ Console.SetCursorPosition(x, y);
+}
+
+char* TANSIParser::GetTerminalID()
+{
+ return "\033[?1;2c";
+}
+
+// All of the Telnet protocol stuff has been moved to TTelHndl.cpp
+// This is more consistent with what OO should be
+// (Paul Brannan 6/15/98)
+
+#ifdef __BORLANDC__
+// argsused doesn't work on MSVC++
+#pragma argsused
+#endif
+
+// Use this for the VT100 flags (Paul Brannan 12/2/98)
+#define FLAG_DOLLAR 0x0001
+#define FLAG_QMARK 0x0002
+#define FLAG_GREATER 0x0004
+#define FLAG_LESS 0x0008
+#define FLAG_EXCLAM 0x0010
+#define FLAG_AMPERSAND 0x0020
+#define FLAG_SLASH 0x0040
+#define FLAG_EQUAL 0x0080
+#define FLAG_QUOTE 0x0100
+#define FLAG_OTHER 0x8000
+
+char* TANSIParser::ParseEscapeANSI(char* pszBuffer, char* pszBufferEnd)
+{
+
+ // The buffer contains something like <ESC>[pA
+ // where p is an optional decimal number specifying the count by which the
+ // appropriate action should take place.
+ // The pointer pszBuffer points us to the p, <ESC> and [ are
+ // already 'consumed'
+
+ // TITUS: Simplification of the code: Assume default count of 1 in case
+ // there are no parameters.
+ char tmpc;
+ const int nParam = 10; // Maximum number of parameters
+ int iParam[nParam] = {1, 0, 0, 0, 0}; // Assume 1 Parameter, Default 1
+ int iCurrentParam = 0;
+ DWORD flag = 0;
+ int missing_param = 0;
+
+ // Get parameters from escape sequence.
+ while ((tmpc = *pszBuffer) <= '?') {
+
+ if(tmpc < '0' || tmpc > '9') {
+ // Check for parameter delimiter.
+ if(tmpc == ';') {
+ // This is a hack (Paul Brannan 6/27/98)
+ if(*(pszBuffer - 1) == '[') missing_param = iCurrentParam+1;
+ pszBuffer++;
+ continue;
+ }
+
+ // It is legal to have control characters inside ANSI sequences
+ // (Paul Brannan 6/26/98)
+ if(tmpc < ' ') {
+ Console.WriteCtrlChar(tmpc);
+ pszBuffer++;
+ continue;
+ }
+
+ // A new way of handling flags (Paul Brannan 12/2/98)
+ switch(tmpc) {
+ case '$': flag |= FLAG_DOLLAR; break;
+ case '?': flag |= FLAG_QMARK; break;
+ case '>': flag |= FLAG_GREATER; break;
+ case '<': flag |= FLAG_LESS; break;
+ case '!': flag |= FLAG_EXCLAM; break;
+ case '&': flag |= FLAG_AMPERSAND; break;
+ case '/': flag |= FLAG_SLASH; break;
+ case '=': flag |= FLAG_EQUAL; break;
+ case '\"': flag |= FLAG_QUOTE; break;
+ default: flag |= FLAG_OTHER; break;
+ }
+
+ pszBuffer++;
+ }
+
+ // Got Numerical Parameter.
+ iParam[iCurrentParam] = strtoul(pszBuffer, &pszBuffer, 10);
+ if (iCurrentParam < nParam)
+ iCurrentParam++;
+ }
+
+ //~~~ TITUS: Apparently the digit is optional (look at termcap or terminfo)
+ // So: If there is no digit, assume a count of 1
+
+ switch ((unsigned char)*pszBuffer++) {
+ // Insert Character
+ case '@':
+ if(iParam[0] == 0) iParam[0] = 1; // Paul Brannan 9/1/98
+ Console.InsertCharacter(iParam[0]); break;
+ // Move cursor up.
+ case 'A':
+ if(iParam[0] == 0) iParam[0] = 1;
+ Console.MoveCursorPosition(0, -iParam[0]); break;
+ // Move cursor down.
+ // Added by I.Ioannou 06 April, 1997
+ case 'B':
+ case 'e':
+ if(iParam[0] == 0) iParam[0] = 1;
+ Console.MoveCursorPosition(0, iParam[0]);
+ break;
+ // Move cursor right.
+ // Added by I.Ioannou 06 April, 1997
+ case 'C':
+ case 'a':
+ // Handle cursor size sequences (Jose Cesar Otero Rodriquez and
+ // Paul Brannan, 3/27/1999)
+ if(flag & FLAG_EQUAL) {
+ switch(iParam[0]) {
+ case 7: Console.SetCursorSize(50); break;
+ case 11: Console.SetCursorSize(6); break;
+ case 32: Console.SetCursorSize(0); break;
+ default: Console.SetCursorSize(13);
+ }
+ } else {
+ if(iParam[0] == 0) iParam[0] = 1;
+ Console.MoveCursorPosition(iParam[0], 0);
+ break;
+ }
+ // Move cursor left.
+ case 'D':
+ if(iParam[0] == 0) iParam[0] = 1;
+ Console.MoveCursorPosition(-iParam[0], 0);
+ break;
+ // Move cursor to beginning of line, p lines down.
+ // Added by I.Ioannou 06 April, 1997
+ case 'E':
+ Console.MoveCursorPosition(-Console.GetCursorX(), iParam[0]);
+ break;
+ // Moves active position to beginning of line, p lines up
+ // Added by I.Ioannou 06 April, 1997
+ // With '=' this changes the default fg color (Paul Brannan 6/27/98)
+ case 'F':
+ if(flag & FLAG_EQUAL)
+ Console.setDefaultFg(iParam[0]);
+ else
+ Console.MoveCursorPosition(-Console.GetCursorX(), -iParam[0]);
+ break;
+ // Go to column p
+ // Added by I.Ioannou 06 April, 1997
+ // With '=' this changes the default bg color (Paul Brannan 6/27/98)
+ case '`':
+ case 'G': // 'G' is from Linux kernel sources
+ if(flag & FLAG_EQUAL) {
+ Console.setDefaultBg(iParam[0]);
+ } else {
+ if (iCurrentParam < 1) // Alter Default
+ iParam[0] = 0;
+ // this was backward, and we should subtract 1 from x
+ // (Paul Brannan 5/27/98)
+ ConSetCursorPos(iParam[0] - 1, Console.GetCursorY());
+ }
+ break;
+ // Set cursor position.
+ case 'f':
+ case 'H':
+ if (iCurrentParam < 2 || iParam[1] < 1)
+ iParam[1] = 1;
+ ConSetCursorPos(iParam[1] - 1, iParam[0] - 1);
+ break;
+ // Clear screen
+ case 'J':
+ if ( iCurrentParam < 1 ) iParam[0] = 0; // Alter Default
+ switch (iParam[0]) {
+ case 0: Console.ClearEOScreen(); break;
+ case 1: Console.ClearBOScreen(); break;
+ case 2:
+ Console.ClearScreen();
+ Console.SetRawCursorPosition(0, 0);
+ break;
+ }
+ break;
+ // Clear line
+ case 'K':
+ if (iCurrentParam < 1) // Alter Default
+ iParam[0] = 0;
+ switch (iParam[0]) {
+ case 0: Console.ClearEOLine(); break;
+ case 1: Console.ClearBOLine(); break;
+ case 2: Console.ClearLine(); break;
+ }
+ break;
+ // Insert p new, blank lines.
+ // Added by I.Ioannou 06 April, 1997
+ case 'L':
+ {
+ // for (int i = 1; i <= iParam[0]; i++)
+ // This should speed things up a bit (Paul Brannan 9/2/98)
+ Console.ScrollDown(Console.GetRawCursorY(), -1, iParam[0]);
+ break;
+ }
+ // Delete p lines.
+ // Added by I.Ioannou 06 April, 1997
+ case 'M':
+ {
+ for (int i = 1; i <= iParam[0]; i++)
+ // This should speed things up a bit (Paul Brannan 9/2/98)
+ Console.ScrollDown(Console.GetRawCursorY(), -1, -1);
+ break;
+ }
+ // DELETE CHAR
+ case 'P':
+ Console.DeleteCharacter(iParam[0]);
+ break;
+ // Scrolls screen up (down? -- PB) p lines,
+ // Added by I.Ioannou 06 April, 1997
+ // ANSI X3.64-1979 references this but I didn't
+ // found it in any telnet implementation
+ // note 05 Oct 97 : but SCO terminfo uses them, so uncomment them !!
+ case 'S':
+ {
+ //for (int i = 1; i <= iParam[0]; i++)
+ // This should speed things up a bit (Paul Brannan 9/2/98)
+ Console.ScrollDown(-1, -1, -iParam[0]);
+ break;
+ }
+ // Scrolls screen up p lines,
+ // Added by I.Ioannou 06 April, 1997
+ // ANSI X3.64-1979 references this but I didn't
+ // found it in any telnet implementation
+ // note 05 Oct 97 : but SCO terminfo uses them, so uncomment them !!
+ case 'T':
+ {
+ // for (int i = 1; i <= iParam[0]; i++)
+ // This should speed things up a bit (Paul Brannan 9/2/98)
+ Console.ScrollDown(-1, -1, iParam[0]);
+ break;
+ }
+ // Erases p characters up to the end of line
+ // Added by I.Ioannou 06 April, 1997
+ case 'X':
+ {
+ int iKeepX = Console.GetRawCursorX();
+ int iKeepY = Console.GetRawCursorY();
+ if (iParam[0] > Console.GetWidth())
+ iParam[0] = Console.GetWidth(); // up to the end of line
+ for ( int i = 1; i <= iParam[0]; i++ )
+ Console.WriteString(" ", 1);
+ Console.SetRawCursorPosition(iKeepX , iKeepY);
+ break;
+ }
+ // Go back p tab stops
+ // Added by I.Ioannou 06 April, 1997
+ // Implemented by Paul Brannan, 4/13/2000
+ case 'Z':
+ {
+ int x = Console.GetCursorX();
+ for(int j = 0; x > 0 && j < iParam[0]; j++)
+ while(x > 0 && tab_stops[j] == tab_stops[x]) x--;
+ Console.SetCursorPosition(x, Console.GetCursorY());
+ }
+ break;
+ // Get Terminal ID
+ case 'c':
+ {
+ char* szTerminalId = GetTerminalID();
+ Network.WriteString(szTerminalId, strlen(szTerminalId));
+ break;
+ }
+ // TITUS++ 2. November 1998: Repeat Character.
+ case 'b':
+ // isprint may be causing problems (Paul Brannan 3/27/99)
+ // if ( isprint(last_char) ) {
+ char buf[150]; // at most 1 line (max 132 chars)
+
+ if ( iParam[0] > 149 ) iParam[0] = 149;
+ memset(buf, last_char, iParam[0]);
+ buf[iParam[0]] = 0;
+ if ( fast_write )
+ Console.WriteStringFast(buf, iParam[0]);
+ else
+ Console.WriteString(buf, iParam[0]);
+ // } /* IF */
+ break;
+ // Go to line p
+ // Added by I.Ioannou 06 April, 1997
+ case 'd':
+ if (iCurrentParam < 1) // Alter Default
+ iParam[0] = 0;
+ // this was backward, and we should subtract 1 from y
+ // (Paul Brannan 5/27/98)
+ ConSetCursorPos(Console.GetCursorX(), iParam[0] - 1);
+ break;
+ // iBCS2 tab erase
+ // Added by I.Ioannou 06 April, 1997
+ case 'g':
+ if (iCurrentParam < 1) // Alter Default
+ iParam[0] = 0;
+ switch (iParam[0]) {
+ case 0:
+ {
+ // Clear the horizontal tab stop at the current active position
+ for(int j = 0; j < MAX_TAB_POSITIONS; j++) {
+ int x = Console.GetCursorX();
+ if(tab_stops[j] == x) tab_stops[j] = tab_stops[x + 1];
+ }
+ }
+ break;
+ case 2:
+ // I think this might be "set as default?"
+ break;
+ case 3:
+ {
+ // Clear all tab stops
+ for(int j = 0; j < MAX_TAB_POSITIONS; j++)
+ tab_stops[j] = -1;
+ }
+ break;
+ }
+ break;
+ // Set extended mode
+ case 'h':
+ {
+ for (int i = 0; i < iCurrentParam; i++) {
+ // Changed to a switch statement (Paul Brannan 5/27/98)
+ if(flag & FLAG_QMARK) {
+ switch(iParam[i]) {
+ case 1: // App cursor keys
+ KeyTrans.set_ext_mode(APP_KEY);
+ break;
+ case 2: // VT102 mode
+ vt52_mode = 0;
+ KeyTrans.unset_ext_mode(APP2_KEY);
+ break;
+ case 3: // 132 columns
+ if(ini.get_wide_enable()) {
+ Console.SetWindowSize(132, -1);
+ }
+ break;
+ case 4: // smooth scrolling
+ break;
+ case 5: // Light background
+ Console.Lightbg();
+ break;
+ case 6: // Stay in margins
+ ignore_margins = 0;
+ break;
+ case 7:
+ Console.setLineWrap(true);
+ break;
+ case 8: // Auto-repeat keys
+ break;
+ case 18: // Send FF to printer
+ break;
+ case 19: // Entire screen legal for printer
+ break;
+ case 25: // Visible cursor
+ break;
+ case 66: // Application numeric keypad
+ break;
+ default:
+#ifdef DEBUG
+ Console.Beep();
+#endif
+ break;
+ }
+ } else {
+ switch(iParam[i]) {
+ case 2: // Lock keyboard
+ break;
+ case 3: // Act upon control codes (PB 12/5/98)
+ print_ctrl = 0;
+ break;
+ case 4: // Set insert mode
+ Console.InsertMode(1);
+ break;
+ case 12: // Local echo off
+ break;
+ case 20: // Newline sends cr/lf
+ KeyTrans.set_ext_mode(APP4_KEY);
+ newline_mode = true;
+ break;
+ default:
+#ifdef DEBUG
+ Console.Beep();
+#endif
+ break;
+ }
+ }
+ }
+ }
+ break;
+ // Print Screen
+ case 'i':
+ if (iCurrentParam < 1)
+ iParam[0]=0;
+ switch (iParam[0]){
+ case 0: break; // Print Screen
+ case 1: break; // Print Line
+ // Added I.Ioannou 06 April, 1997
+ case 4:
+ // Stop Print Log
+ InPrintMode = 0;
+ if ( printfile != NULL )
+ fclose(printfile);
+ break;
+ case 5:
+ // Start Print Log
+ printfile = fopen(ini.get_printer_name(), "ab");
+ if (printfile != NULL) InPrintMode = 1;
+ break;
+ }
+ break;
+ // Unset extended mode
+ case 'l':
+ {
+ for (int i = 0; i < iCurrentParam; i++) {
+ // Changed to a switch statement (Paul Brannan 5/27/98)
+ if(flag & FLAG_QMARK) {
+ switch(iParam[i]) {
+ case 1: // Numeric cursor keys
+ KeyTrans.unset_ext_mode(APP_KEY);
+ break;
+ case 2: // VT52 mode
+ vt52_mode = 1;
+ KeyTrans.set_ext_mode(APP2_KEY);
+ break;
+ case 3: // 80 columns
+ if(ini.get_wide_enable()) {
+ Console.SetWindowSize(80, -1);
+ }
+ break;
+ case 4: // jump scrolling
+ break;
+ case 5: // Dark background
+ Console.Darkbg();
+ break;
+ case 6: // Ignore margins
+ ignore_margins = 1;
+ break;
+ case 7:
+ Console.setLineWrap(false);
+ break;
+ case 8: // Auto-repeat keys
+ break;
+ case 19: // Only send scrolling region to printer
+ break;
+ case 25: // Invisible cursor
+ break;
+ case 66: // Numeric keypad
+ break;
+ default:
+#ifdef DEBUG
+ Console.Beep();
+#endif
+ break;
+ }
+ } else {
+ switch(iParam[i]) {
+ case 2: // Unlock keyboard
+ break;
+ case 3: // Display control codes (PB 12/5/98)
+ print_ctrl = 1;
+ break;
+ case 4: // Set overtype mode
+ Console.InsertMode(0);
+ break;
+ case 12: // Local echo on
+ break;
+ case 20: // sends lf only
+ KeyTrans.unset_ext_mode(APP4_KEY);
+ newline_mode = false;
+ break;
+ default:
+#ifdef DEBUG
+ Console.Beep();
+#endif
+ break;
+ }
+ }
+ }
+ }
+ break;
+ // Set color
+ case 'm':
+ if(missing_param) Console.Normal();
+ if(iCurrentParam == 0) {
+ Console.Normal();
+ } else {
+ for(int i = 0; i < iCurrentParam; i++)
+ ConSetAttribute(iParam[i]);
+ }
+ break;
+ // report cursor position Row X Col
+ case 'n':
+ if (iCurrentParam == 1 && iParam[0]==5) {
+ // report the cursor position
+ Network.WriteString("\x1B[0n", 6);
+ break;
+ }
+ if (iCurrentParam == 1 && iParam[0]==6){
+ // report the cursor position
+ // The cursor position needs to be sent as a single string
+ // (Paul Brannan 6/27/98)
+ char szCursorReport[40] = "\x1B[";
+
+ itoa(Console.GetCursorY() + 1,
+ &szCursorReport[strlen(szCursorReport)], 10);
+ strcat(szCursorReport, ";");
+ itoa(Console.GetCursorX() + 1,
+ &szCursorReport[strlen(szCursorReport)], 10);
+ strcat(szCursorReport, "R");
+
+ Network.WriteString(szCursorReport, strlen(szCursorReport));
+
+ }
+ break;
+ // Miscellaneous weird sequences (Paul Brannan 6/27/98)
+ case 'p':
+ // Set conformance level
+ if(flag & FLAG_QUOTE) {
+ break;
+ }
+ // Soft terminal reset
+ if(flag & FLAG_EXCLAM) {
+ break;
+ }
+ // Report mode settings
+ if(flag & FLAG_DOLLAR) {
+ break;
+ }
+ break;
+ // Scroll Screen
+ case 'r':
+ if (iCurrentParam < 1) {
+ // Enable scrolling for entire display
+ Console.SetScroll(-1, -1);
+ break;
+ }
+ if (iCurrentParam >1) {
+ // Enable scrolling from row1 to row2
+ Console.SetScroll(iParam[0] - 1, iParam[1] - 1);
+ // If the cursor is outside the scrolling range, fix it
+ // (Paul Brannan 6/26/98)
+ // if(Console.GetRawCursorY() < iParam[0] - 1) {
+ // Console.SetRawCursorPosition(Console.GetCursorX(),
+ // iParam[0] - 1);
+ // }
+ // if(Console.GetRawCursorY() > iParam[1] - 1) {
+ // Console.SetRawCursorPosition(Console.GetCursorX(),
+ // iParam[1] - 1);
+ // }
+ }
+ // Move the cursor to the home position (Paul Brannan 12/2/98)
+ Console.SetCursorPosition(0, 0);
+ break;
+ // Save cursor position
+ case 's':
+ SaveCurY(Console.GetRawCursorY());
+ SaveCurX(Console.GetRawCursorX());
+ break;
+ // Restore cursor position
+ case 'u':
+ Console.SetRawCursorPosition(iSavedCurX, iSavedCurY);
+ break;
+ // DEC terminal report (Paul Brannan 6/28/98)
+ case 'x':
+ if(iParam[0])
+ Network.WriteString("\033[3;1;1;128;128;1;0x", 20);
+ else
+ Network.WriteString("\033[2;1;1;128;128;1;0x", 20);
+ break;
+ default:
+#ifdef DEBUG
+ Console.Beep();
+#endif
+ break;
+ }
+
+ return pszBuffer;
+}
+
+#ifdef MTE_SUPPORT
+// Added by Frediano Ziglio, 5/31/2000
+// MTE extension
+// initially copied from ParseEscapeANSI
+char* TANSIParser::ParseEscapeMTE(char* pszBuffer, char* pszBufferEnd)
+{
+ // The buffer contains something like <ESC>~pA
+ // where p is an optional decimal number specifying the count by which the
+ // appropriate action should take place.
+ // The pointer pszBuffer points us to the p, <ESC> and ~ are
+ // already 'consumed'
+ // TITUS: Simplification of the code: Assume default count of 1 in case
+ // there are no parameters.
+ char tmpc;
+ const int nParam = 10; // Maximum number of parameters
+ int iParam[nParam] = {1, 0, 0, 0, 0}; // Assume 1 parameter, Default 1
+ int iCurrentParam = 0;
+ char sRepeat[2];
+
+ // Get parameters from escape sequence.
+ while ((tmpc = *pszBuffer) <= '?') {
+ if(tmpc < '0' || tmpc > '9') {
+ // Check for parameter delimiter.
+ if(tmpc == ';') {
+ pszBuffer++;
+ continue;
+ }
+ pszBuffer++;
+ }
+
+ // Got Numerical Parameter.
+ iParam[iCurrentParam] = strtoul(pszBuffer, &pszBuffer, 10);
+ if (iCurrentParam < nParam)
+ iCurrentParam++;
+ }
+
+ //~~~ TITUS: Apparently the digit is optional (look at termcap or terminfo)
+ // So: If there is no digit, assume a count of 1
+
+ switch ((unsigned char)*pszBuffer++) {
+ case 'A':
+ // set colors
+ if (iCurrentParam < 2 )
+ break;
+ if (iParam[0] <= 15 && iParam[1] <= 15)
+ Console.SetAttrib( (iParam[1] << 4) | iParam[0] );
+ break;
+
+ case 'R':
+ // define region
+ mteRegionXF = -1;
+ if (iCurrentParam < 2 )
+ break;
+ mteRegionXF = iParam[1]-1;
+ mteRegionYF = iParam[0]-1;
+ break;
+
+ case 'F':
+ // fill with char
+ {
+ if (mteRegionXF == -1 || iCurrentParam < 1)
+ break;
+ sRepeat[0] = (char)iParam[0];
+ sRepeat[1] = '\0';
+ int xi = Console.GetCursorX(),yi = Console.GetCursorY();
+ int xf = mteRegionXF;
+ int yf = mteRegionYF;
+ mteRegionXF = -1;
+ for(int y=yi;y<=yf;++y)
+ {
+ Console.SetCursorPosition(xi,y);
+ for(int x=xi;x<=xf;++x)
+
+ Console.WriteStringFast(sRepeat,1);
+ }
+ }
+ break;
+
+ case 'S':
+ // Scroll region
+ {
+ if (mteRegionXF == -1 || iCurrentParam < 2)
+ break;
+ int /*x = Console.GetCursorX(),*/y = Console.GetCursorY();
+ // int xf = mteRegionXF;
+ int yf = mteRegionYF;
+ mteRegionXF = -1;
+ // !!! don't use x during scroll
+ int diff = (iParam[0]-1)-y;
+ if (diff<0)
+ Console.ScrollDown(y-1,yf,diff);
+ else
+ Console.ScrollDown(y,yf+1,diff);
+ }
+ break;
+ // Meridian main version ??
+ case 'x':
+ // disable echo and line mode
+ Network.set_local_echo(0);
+ Network.set_line_mode(0);
+ // Meridian Server handle cursor itself
+ Console.SetCursorSize(0);
+ break;
+ // query ??
+ case 'Q':
+ if (iParam[0] == 1)
+ Network.WriteString("\033vga.",5);
+ break;
+ default:
+#ifdef DEBUG
+ Console.Beep();
+#endif
+ break;
+ }
+
+ return pszBuffer;
+ }
+#endif
+
+char* TANSIParser::ParseEscape(char* pszBuffer, char* pszBufferEnd) {
+ char *pszChar;
+
+ // Check if we have enough characters in buffer.
+ if ((pszBufferEnd - pszBuffer) < 2)
+ return pszBuffer;
+
+ // I.Ioannou 04 Sep 1997
+ // there is no need for pszBuffer++; after each command
+
+ // Decode the command.
+ pszBuffer++;
+
+ switch (*pszBuffer++) {
+ case 'A': // Cursor up
+ Console.MoveCursorPosition(0, -1);
+ break;
+ // Cursor down
+ case 'B':
+ Console.MoveCursorPosition(0, 1);
+ break;
+ // Cursor right
+ case 'C':
+ Console.MoveCursorPosition(1, 0);
+ break;
+ // LF *or* cursor left (Paul Brannan 6/27/98)
+ case 'D':
+ if(vt52_mode)
+ Console.MoveCursorPosition(-1, 0);
+ else
+ Console.index();
+ break;
+ // CR/LF (Paul Brannan 6/26/98)
+ case 'E':
+ Console.WriteCtrlString("\r\n", 2);
+ break;
+ // Special graphics char set (Paul Brannan 6/27/98)
+ case 'F':
+ Charmap.setmap('0');
+ break;
+ // ASCII char set (Paul Brannan 6/27/98)
+ case 'G':
+ Charmap.setmap('B');
+ break;
+ // Home cursor/tab set
+ case 'H':
+ if(ini.get_vt100_mode()) {
+ int x = Console.GetCursorX();
+ if(x != 0) {
+ int t = tab_stops[x - 1];
+ for(int j = x - 1; j >= 0 && tab_stops[j] == t; j--)
+ tab_stops[j] = x;
+ }
+ } else {
+ // I.Ioannou 04 Sep 1997 (0,0) not (1,1)
+ ConSetCursorPos(0, 0);
+ }
+ break;
+ // Reverse line feed (Paul Brannan 6/27/98)
+ // FIX ME!!! reverse_index is wrong to be calling here
+ // (Paul Brannan 12/2/98)
+ case 'I':
+ Console.reverse_index();
+ break;
+ // Erase end of screen
+ case 'J':
+ Console.ClearEOScreen();
+ break;
+ // Erase EOL
+ case 'K':
+ Console.ClearEOLine();
+ break;
+ // Scroll Up one line //Reverse index
+ case 'M':
+ Console.reverse_index();
+ break;
+ // Direct cursor addressing
+ case 'Y':
+ if ((pszBufferEnd - pszBuffer) >= 2){
+ // if we subtract '\x1F', then we may end up with a negative
+ // cursor position! (Paul Brannan 6/26/98)
[truncated at 1000 lines; 478 more skipped]
reactos/apps/utils/net/telnet/src
diff -N ansiprsr.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ansiprsr.h 21 Nov 2004 22:24:56 -0000 1.1
@@ -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
reactos/apps/utils/net/telnet/src
diff -N keytrans.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ keytrans.cpp 21 Nov 2004 22:24:56 -0000 1.1
@@ -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;
+};
reactos/apps/utils/net/telnet/src
diff -N keytrans.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ keytrans.h 21 Nov 2004 22:24:56 -0000 1.1
@@ -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
reactos/apps/utils/net/telnet/src
diff -N stl_bids.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ stl_bids.h 21 Nov 2004 22:24:56 -0000 1.1
@@ -0,0 +1,159 @@
+// 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;
+ typedef size_t size_type;
+ typedef typename vector<T>::const_iterator const_iterator;
+ const size_type lowerbound;
+public:
+ TArrayAsVector(size_type upper,
+ size_type lower = 0,
+ int delta = 0) :
+ vector<T>( ),
+ growable(delta),
+ lowerbound(lower)
+ { vector<T>::reserve(upper-lower + 1);}
+
+ ~TArrayAsVector( )
+ { // This call is unnecessary? (Paul Brannan 5/7/98)
+ // vector<T>::~vector( );
+ }
+
+ int Add(const T& item)
+ { if(!growable && vector<T>::size( ) == vector<T>::capacity( ))
+ return 0;
+ else
+ insert(vector<T>::end( ), item);
+ return 1; }
+
+ int AddAt(const T& item, size_type index)
+ { if(!growable &&
+ ((vector<T>::size( ) == vector<T>::capacity( )) ||
+ (ZeroBase(index > vector<T>::capacity( )) )))
+ return 0;
+ if(ZeroBase(index) > vector<T>::capacity( )) // out of bounds
+ { insert(vector<T>::end( ),
+ ZeroBase(index) - vector<T>::size( ), T( ));
+ insert(vector<T>::end( ), item); }
+ else
+ { insert(vector<T>::begin( ) + ZeroBase(index), item); }
+ return 1;
+ }
+
+ size_type ArraySize( )
+ { return vector<T>::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(vector<T>::begin( ) + ZeroBase(index)); }
+
+ void Detach(const T& item)
+ { Destroy(Find(item)); }
+
+ void Destroy(size_type index)
+ { erase(vector<T>::begin( ) + ZeroBase(index)); }
+
+ void Destroy(const T& item)
+ { Destroy(Find(item)); }
+
+ size_type Find(const T& item) const
+ { const_iterator location = find(vector<T>::begin( ),
+ vector<T>::end( ), item);
+ if(location != vector<T>::end( ))
+ return BoundBase(size_type(location -
+ vector<T>::begin( )));
+ else
+ return INT_MAX; }
+
+ size_type GetItemsInContainer( )
+ { return vector<T>::size( ); }
+
+ void Grow(size_type index)
+ { if( index < lowerbound )
+ Reallocate(ArraySize( ) + (index -
+ lowerbound));
+ else if( index >= BoundBase(vector<T>::size( )))
+ Reallocate(ZeroBase(index) ); }
+
+ int HasMember(const T& item)
+ { if(Find(item) != INT_MAX)
+ return 1;
+ else
+ return 0; }
+
+ int IsEmpty( )
+ { return vector<T>::empty( ); }
+
+ int IsFull( )
+ { if(growable)
+ return 0;
+ if(vector<T>::size( ) == vector<T>::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( )
+ {
+ vector<T>::clear();
+ }
+
+ void Reallocate(size_type sz,
+ size_type offset = 0)
+ { if(offset)
+ insert(vector<T>::begin( ), offset, T( ));
+ vector<T>::reserve(sz);
+ erase(vector<T>::end( ) - offset, vector<T>::end( )); }
+
+ void RemoveEntry(size_type index)
+ { Detach(index); }
+
+ void SetData(size_type index, const T& item)
+ { (*this)[index] = item; }
+
+ size_type UpperBound( )
+ { return BoundBase(vector<T>::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
reactos/apps/utils/net/telnet/src
diff -N tcharmap.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tcharmap.cpp 21 Nov 2004 22:24:56 -0000 1.1
@@ -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[(unsigned char)'B'] = mapB;
+ map[(unsigned char)'A'] = mapA;
+ if(ini.get_fast_write()) {
+ map[(unsigned char)'0'] = map0_safe;
+ map[(unsigned char)'2'] = map0_safe;
+ } else {
+ map[(unsigned char)'0'] = map0;
+ map[(unsigned char)'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[(unsigned char)mapchar]) {
+ map[(unsigned char)mapchar] = new char[256];
+ for(int j = 0; j < 256; j++) map[(unsigned char)mapchar][(unsigned char)pos] = j;
+ }
+ map[(unsigned char)mapchar][(unsigned char)pos] = c;
+}
reactos/apps/utils/net/telnet/src
diff -N tcharmap.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tcharmap.h 21 Nov 2004 22:24:56 -0000 1.1
@@ -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[(unsigned char)mapchar]) return map[(unsigned char)mapchar][(unsigned char)c];
+ return c;
+ }
+ char translate(char c) {
+ return current_map[(unsigned char)c];
+ }
+
+ void setmap(char mapchar) {
+ if(map[(unsigned char)mapchar]) current_map = map[(unsigned char)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
reactos/apps/utils/net/telnet/src
diff -N tconsole.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tconsole.cpp 21 Nov 2004 22:24:56 -0000 1.1
@@ -0,0 +1,1008 @@
+///////////////////////////////////////////////////////////////////////////////
+//Telnet Win32 : an ANSI telnet client.
+//Copyright (C) 1998-2000 Paul Brannan
+//Copyright (C) 1998 I.Ioannou
+//Copyright (C) 1997 Brad Johnson
+//
+//This program is free software; you can redistribute it and/or
+//modify it under the terms of the GNU General Public License
+//as published by the Free Software Foundation; either version 2
+//of the License, or (at your option) any later version.
+//
+//This program is distributed in the hope that it will be useful,
+//but WITHOUT ANY WARRANTY; without even the implied warranty of
+//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+//GNU General Public License for more details.
+//
+//You should have received a copy of the GNU General Public License
+//along with this program; if not, write to the Free Software
+//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+//I.Ioannou
+//roryt@hol.gr
+//
+///////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Module: tconsole.cpp
+//
+// Contents: screen functions
+//
+// Product: telnet
+//
+//
+// Revisions: Mar. 29, 2000 pbranna@clemson (Paul Brannan)
+// June 15, 1998 pbranna@clemson.edu
+// May 16, 1998 pbranna@clemson.edu
+// 05. Sep.1997 roryt@hol.gr (I.Ioannou)
+// 11.May,1997 roryt@hol.gr
+// 06.April,1997 roryt@hol.gr
+// 30.M�rz.1997 Titus_Boxberg@public.uni-hamburg.de
+// 5.Dec.1996 jbj@nounname.com
+// Version 2.0
+// 02.Apr.1995 igor.milavec@uni-lj.si
+// Original code
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#include <windows.h>
+#include "tconsole.h"
+
+// argsused doesn't work on MSVC++
+#ifdef __BORLANDC__
+#pragma argsused
+#endif
+
+TConsole::TConsole(HANDLE h) {
+ hConsole = h;
+
+ GetConsoleScreenBufferInfo(hConsole, &ConsoleInfo);
+
+ // Start with correct colors
+ int fg = ini.get_normal_fg();
+ int bg = ini.get_normal_bg();
+ if(fg == -1)
+ fg = defaultfg = origfg = ConsoleInfo.wAttributes & 0xF;
+ else
+ defaultfg = origfg = fg;
+ if(bg == -1)
+ bg = defaultbg = origbg = (ConsoleInfo.wAttributes >> 4) & 0xF;
+ else
+ defaultbg = origbg = bg;
+ wAttributes = fg | (bg << 4);
+ reverse = blink = underline = false;
+ SetConsoleTextAttribute(hConsole, wAttributes);
+
+ insert_mode = 0;
+
+ // Set the screen size
+ SetWindowSize(ini.get_term_width(), ini.get_term_height());
+
+ iScrollStart = -1;
+ iScrollEnd = -1;
+}
+
+TConsole::~TConsole() {
+ wAttributes = origfg | (origbg << 4);
+ SetCursorPosition(0, CON_HEIGHT);
+ SetConsoleTextAttribute(hConsole, wAttributes);
+ WriteCtrlChar('\x0a');
+}
+
+// Paul Brannan 8/2/98
+void TConsole::SetWindowSize(int width, int height) {
+ SMALL_RECT sr = {
+ CON_LEFT,
+ CON_TOP,
+ (width == -1) ? CON_RIGHT : CON_LEFT + width - 1,
+ (height == -1) ? CON_BOTTOM : CON_TOP + height - 1
+ };
+ ConsoleInfo.dwSize.X = width;
+ if(ConsoleInfo.dwSize.Y < height) ConsoleInfo.dwSize.Y = height;
+ SetConsoleScreenBufferSize(hConsole, ConsoleInfo.dwSize);
+ SetConsoleWindowInfo(hConsole, TRUE, &sr);
+ SetConsoleScreenBufferSize(hConsole, ConsoleInfo.dwSize);
+ sync();
+}
+
+// Paul Brannan 5/15/98
+void TConsole::sync() {
+ GetConsoleScreenBufferInfo(hConsole, &ConsoleInfo);
+}
+
+void TConsole::HighVideo() {
+ wAttributes = wAttributes | (unsigned char) 8;
+}
+
+void TConsole::LowVideo() {
+ wAttributes = wAttributes & (unsigned char) (0xff-8);
+}
+
+void TConsole::Normal() {
+ // I.Ioannou 11 May 1997
+ // Color 7 is correct on some systems (for example Linux)
+ // but not with others (for example SCO)
+ // we must preserve the colors :
+ // 06/04/98 thanks to Paul a .ini parameter from now on
+
+ BlinkOff();
+ UnderlineOff();
+ if(ini.get_preserve_colors()) {
+ ReverseOff();
+ LowVideo();
+ } else {
+ fg = defaultfg;
+ bg = defaultbg;
+ wAttributes = (unsigned char)fg | (bg << 4);
+ reverse = false;
+ }
+}
+
+void TConsole::SetForeground(unsigned char wAttrib) {
+ if(reverse) bg = wAttrib; else fg = wAttrib;
+ wAttributes = (wAttributes & (unsigned char)0x88) |
+ (unsigned char)fg | (bg << 4);
+}
+
+void TConsole::SetBackground(unsigned char wAttrib) {
+ if(reverse) fg = wAttrib; else bg = wAttrib;
+ wAttributes = (wAttributes & (unsigned char)0x88) |
+ (unsigned char)fg | (bg << 4);
+}
+
+// As far as I can tell, there's no such thing as blink in Windows Console.
+// I tried using some inline asm to turn off high-intensity backgrounds,
+// but I got a BSOD. Perhaps there is an undocumented function?
+// (Paul Brannan 6/27/98)
+void TConsole::BlinkOn() {
+ blink = 1;
+ if(underline) {
+ UlBlinkOn();
+ } else {
+ if(ini.get_blink_bg() != -1) {
+ wAttributes &= 0x8f; // turn off bg
+ wAttributes |= ini.get_blink_bg() << 4;
+ }
+ if(ini.get_blink_fg() != -1) {
+ wAttributes &= 0xf8; // turn off fg
+ wAttributes |= ini.get_blink_fg();
+ }
+ if(ini.get_blink_bg() == -1 && ini.get_blink_fg() == -1)
+ wAttributes |= 0x80;
+ }
+}
+
+// Added by I.Ioannou 06 April, 1997
+void TConsole::BlinkOff() {
+ blink = 0;
+ if(underline) {
+ UlBlinkOff();
+ } else {
+ if(ini.get_blink_bg() != -1) {
+ wAttributes &= 0x8f; // turn off bg
+ wAttributes |= defaultbg << 4;
+ }
+ if(ini.get_blink_fg() != -1) {
+ wAttributes &= 0xf8; // turn off fg
+ wAttributes |= defaultfg;
+ }
+ if(ini.get_blink_bg() == -1 && ini.get_blink_fg() == -1)
+ wAttributes &= 0x7f;
+ }
+}
+
+// Paul Brannan 6/27/98
+void TConsole::UnderlineOn() {
+ underline = 1;
+ if(blink) {
+ UlBlinkOn();
+ } else {
+ if(ini.get_underline_bg() != -1) {
+ wAttributes &= 0x8f; // turn off bg
+ wAttributes |= ini.get_underline_bg() << 4;
+ }
+ if(ini.get_underline_fg() != -1) {
+ wAttributes &= 0xf8; // turn off fg
+ wAttributes |= ini.get_underline_fg();
+ }
+ if(ini.get_underline_bg() == -1 && ini.get_underline_fg() == -1)
+ wAttributes |= 0x80;
+ }
+}
+
+// Paul Brannan 6/27/98
+void TConsole::UnderlineOff() {
+ underline = 0;
+ if(blink) {
+ UlBlinkOff();
+ } else {
+ if(ini.get_blink_bg() != -1) {
+ wAttributes &= 0x8f; // turn off bg
+ wAttributes |= defaultbg << 4;
+ }
+ if(ini.get_blink_fg() != -1) {
+ wAttributes &= 0xf8; // turn off fg
+ wAttributes |= defaultfg;
+ }
+ if(ini.get_blink_bg() == -1 && ini.get_blink_fg() == -1)
+ wAttributes &= 0x7f;
+ }
+}
+
+// Paul Brannan 6/27/98
+void TConsole::UlBlinkOn() {
+ if(ini.get_ulblink_bg() != -1) {
+ wAttributes &= 0x8f; // turn off bg
+ wAttributes |= ini.get_ulblink_bg() << 4;
+ }
+ if(ini.get_ulblink_fg() != -1) {
+ wAttributes &= 0xf8; // turn off fg
+ wAttributes |= ini.get_ulblink_fg();
+ }
+ if(ini.get_ulblink_bg() == -1 && ini.get_ulblink_fg() == -1)
+ wAttributes |= 0x80;
+}
+
+// Paul Brannan 6/27/98
+void TConsole::UlBlinkOff() {
+ if(blink) {
+ BlinkOn();
+ } else if(underline) {
+ UnderlineOn();
+ } else {
+ Normal();
+ }
+}
+
+// Paul Brannan 6/26/98
+void TConsole::Lightbg() {
+ WORD *pAttributes = new WORD[CON_COLS];
+ DWORD Result;
+
+ // Paul Brannan 8/5/98
+ // Correction: processing more than one line at a time causes a segfault
+ // if the screen width != 80
+ for(int i = CON_TOP; i <= CON_BOTTOM; i++) {
+ COORD Coord = {CON_LEFT, i};
+
+ ReadConsoleOutputAttribute(hConsole, pAttributes, (DWORD)(CON_COLS),
+ Coord, &Result);
+
+ for(DWORD j = 0; j < Result; j++) pAttributes[j] |= 0x80;
+
+ WriteConsoleOutputAttribute(hConsole, pAttributes, Result, Coord,
+ &Result);
+ }
+
+ delete[] pAttributes; // clean up
+
+ wAttributes |= (unsigned char)0x80;
+ bg |= 8;
+}
+
+// Paul Brannan 6/26/98
+void TConsole::Darkbg() {
+ WORD *pAttributes = new WORD[CON_COLS];
+ DWORD Result;
+
+ // Paul Brannan 8/5/98
+ // Correction: processing more than one line at a time causes a segfault
+ // if the screen width != 80
+ for(int i = CON_TOP; i <= CON_BOTTOM; i++) {
+ COORD Coord = {CON_LEFT, i};
+
+ ReadConsoleOutputAttribute(hConsole, pAttributes, (DWORD)(CON_COLS),
+ Coord, &Result);
+
+ for(DWORD j = 0; j < Result; j++) pAttributes[j] &= 0x7f;
+
+ WriteConsoleOutputAttribute(hConsole, pAttributes, Result, Coord,
+ &Result);
+ }
+
+ delete[] pAttributes; // clean up
+
+
+ wAttributes &= (unsigned char)0x7f;
+ bg &= 7;
+}
+
+// Added by I.Ioannou 11.May,1997
+void TConsole::ReverseOn() {
+ if (!reverse) {
+ reverse = true;
+
+ // atl : forground attributes without the intensity
+ // ath : backgound attributes without the blink
+ // bl : the blink state
+ // ints : the intensity
+ unsigned char atl = wAttributes & (unsigned char) 0x07;
+ unsigned char ath = wAttributes & (unsigned char) 0x70;
+ unsigned char bl = wAttributes & (unsigned char) 0x80;
+ unsigned char ints = wAttributes & (unsigned char) 0x08;
+ wAttributes = bl | (atl << 4) | ints | (ath >> 4);
+ }
+}
+
+// Added by I.Ioannou 11.May,1997
+void TConsole::ReverseOff() {
+ if (reverse) {
+ reverse = false;
+ wAttributes = fg | (bg << 4);
+ }
+}
+
+unsigned long TConsole::WriteText(const char *pszString, unsigned long cbString) {
+ DWORD Result;
+
+ if(insert_mode) {
+ InsertCharacter(cbString);
+ }
+
+ WriteConsoleOutputCharacter(hConsole, (char *)pszString, cbString,
+ ConsoleInfo.dwCursorPosition, &Result);
+ FillConsoleOutputAttribute(hConsole, wAttributes, cbString,
+ ConsoleInfo.dwCursorPosition, &Result);
+ return Result;
+}
+
+// Formerly ConWriteString (Paul Brannan 6/28/98)
+unsigned long TConsole::WriteStringFast(const char* pszString, unsigned long cbString) {
+ DWORD Result;
+
+ SetConsoleTextAttribute(hConsole, wAttributes);
+
+ //check to see if the line is longer than the display
+ if (!getLineWrap() && ((unsigned)CON_CUR_X + cbString) >= (unsigned)CON_COLS) {
+ // Take care of the last line last colum exception...
+ // The display scrolls up if you use the normal char out
+ // function even if you only write to the last place
+ // on the line. :-(
+ if ((unsigned)CON_CUR_Y >= (unsigned)CON_HEIGHT) {
+ unsigned long iFakeResult = cbString;
+ cbString = CON_COLS - CON_CUR_X - 1;
+
+ // FIX ME !!! This will avoid the exception when cbString
+ // is <= 0 but still doesn't work :-(
+ if (cbString > 0)
+ WriteConsole(hConsole, pszString, cbString, &Result, 0);
+
+ COORD dwBufferCoord;
+ dwBufferCoord.X = 0;
+ dwBufferCoord.Y = 0;
+
+ CHAR_INFO ciBuffer;
+ ciBuffer.Char.AsciiChar = *(pszString+cbString);
+ ciBuffer.Attributes = wAttributes;
+ SMALL_RECT srWriteRegion;
+ srWriteRegion.Top = (SHORT) CON_BOTTOM;
+ srWriteRegion.Bottom = (SHORT) CON_BOTTOM;
+ srWriteRegion.Left = (SHORT) CON_RIGHT;
+ srWriteRegion.Right = (SHORT) CON_RIGHT;
+
+ COORD bufSize = {1,1};
+
+ WriteConsoleOutput(hConsole, &ciBuffer, bufSize,
+ dwBufferCoord, &srWriteRegion);
+
+ // We need to update the ConsoleInfo struct now (Paul Brannan 5/9/98)
+ ConsoleInfo.dwCursorPosition.X = CON_RIGHT;
+
+ return iFakeResult; // Skip the chars that did not fit
+ }
+ // just write the line up to the end
+ else {
+ int iFakeResult = cbString;
+ cbString = CON_COLS - CON_CUR_X;
+
+ if(cbString > 0) {
+ WriteConsole(hConsole, pszString, cbString, &Result, 0);
+
+ // We need to update the ConsoleInfo struct now (Paul Brannan 5/9/98)
+ ConsoleInfo.dwCursorPosition.X += (unsigned short)Result;
+ }
+
+ return iFakeResult; // Skip the chars that did not fit
+ }
+ } else {
+ // If custom scrolling is enabled we must take care of it
+ if(iScrollStart != -1 || iScrollEnd != -1) {
+ return WriteString(pszString, cbString);
+ }
+
+ // Apparently VT100 terminals have an invisible "81st" column that
+ // can hold a cursor until another character is printed. I'm not sure
+ // exactly how to handle this, but here's a hack (Paul Brannan 5/28/98)
+ if(ini.get_vt100_mode() && cbString + (unsigned)CON_CUR_X == (unsigned)CON_COLS) {
+
+ cbString--;
+ if(cbString >= 0) WriteConsole(hConsole, pszString, cbString, &Result, 0);
+
+ COORD dwBufferCoord;
+ dwBufferCoord.X = 0;
+ dwBufferCoord.Y = 0;
+
+ CHAR_INFO ciBuffer;
+ ciBuffer.Char.AsciiChar = *(pszString+cbString);
+ ciBuffer.Attributes = wAttributes;
+ SMALL_RECT srWriteRegion;
+ srWriteRegion.Top = (SHORT) ConsoleInfo.dwCursorPosition.Y;
+ srWriteRegion.Bottom = (SHORT) ConsoleInfo.dwCursorPosition.Y;
+ srWriteRegion.Left = (SHORT) CON_RIGHT;
+ srWriteRegion.Right = (SHORT) CON_RIGHT;
+
+ COORD bufSize = {1,1};
+
+ WriteConsoleOutput(hConsole, &ciBuffer, bufSize,
+ dwBufferCoord, &srWriteRegion);
+
+ // Update the ConsoleInfo struct
+ ConsoleInfo.dwCursorPosition.X = CON_RIGHT + 1;
+
+ return Result + 1;
+ }
+
+ // normal line will wrap normally or not to the end of buffer
+ WriteConsole(hConsole, pszString, cbString, &Result, 0);
+
+ // We need to update the ConsoleInfo struct now (Paul Brannan 5/9/98)
+ // FIX ME!!! This is susceptible to the same problem as above.
+ // (e.g. we write out 160 characters)
+ ConsoleInfo.dwCursorPosition.X += (unsigned short)Result;
+ while(CON_CUR_X > CON_WIDTH) {
+ ConsoleInfo.dwCursorPosition.X -= ConsoleInfo.dwSize.X;
+ if((unsigned)CON_CUR_Y < (unsigned)CON_HEIGHT) {
+ ConsoleInfo.dwCursorPosition.Y++;
+ } else {
+ // If we aren't at the bottom of the window, then we need to
+ // scroll down (Paul Brannan 4/14/2000)
+ if(ConsoleInfo.srWindow.Bottom < ConsoleInfo.dwSize.Y - 1) {
+ ConsoleInfo.srWindow.Top++;
+ ConsoleInfo.srWindow.Bottom++;
+ ConsoleInfo.dwCursorPosition.Y++;
+ SetConsoleWindowInfo(hConsole, TRUE, &ConsoleInfo.srWindow);
+ }
+ }
+ }
+ }
+
+ return Result;
+
+}
+
+unsigned long TConsole::WriteString(const char* pszString, unsigned long cbString) {
+ DWORD Result = 0;
+
+ SetConsoleTextAttribute(hConsole, wAttributes);
+
+ //check to see if the line is longer than the display
+ if (!getLineWrap()){
+ unsigned long iFakeResult = cbString;
+ if((CON_CUR_X + cbString) >= (unsigned int)CON_COLS)
+ cbString = CON_COLS - CON_CUR_X;
+ if(cbString > 0)
+ Result = WriteText(pszString, cbString);
+
+ // We need to update the ConsoleInfo struct now (Paul Brannan 5/9/98)
+ ConsoleInfo.dwCursorPosition.X += (unsigned short)Result;
+ SetConsoleCursorPosition(hConsole, ConsoleInfo.dwCursorPosition);
+
+ return iFakeResult; // Skip the chars that did not fit
+ } else {
+ // Write up to the end of the line
+ unsigned long temp = cbString;
+ if((CON_CUR_X + temp) > (unsigned int)CON_COLS) {
+ temp = CON_COLS - CON_CUR_X;
+ } else {
+ Result = WriteText(pszString, temp);
+ ConsoleInfo.dwCursorPosition.X += (unsigned short)Result;
+ SetConsoleCursorPosition(hConsole, ConsoleInfo.dwCursorPosition);
+ return Result;
+ }
+ if(temp > 0) {
+ Result = WriteText(pszString, temp);
+ ConsoleInfo.dwCursorPosition.X += (unsigned short)Result;
+ temp = (unsigned short)Result;
+ }
+
+ // keep writing lines until we get to less than 80 chars left
+ while((temp + (unsigned int)CON_COLS) < cbString) {
+ index(); // LF
+ ConsoleInfo.dwCursorPosition.X = 0; // CR
+ Result = WriteText(&pszString[temp], CON_COLS);
+ temp += (unsigned short)Result;
+ }
+
+ // write out the last bit
+ if(temp < cbString) {
+ index();
+ ConsoleInfo.dwCursorPosition.X = 0;
+ Result = WriteText(&pszString[temp], cbString - temp);
+ temp += (unsigned short)Result;
+ }
+
+ // Apparently VT100 terminals have an invisible "81st" column that
+ // can hold a cursor until another character is printed. I'm not sure
+ // exactly how to handle this, but here's a hack (Paul Brannan 5/28/98)
+ if(!ini.get_vt100_mode() && cbString + (unsigned)ConsoleInfo.dwCursorPosition.X
+ == (unsigned int)CON_COLS) {
+ index();
+ ConsoleInfo.dwCursorPosition.X = 0;
+ }
+
+ SetConsoleCursorPosition(hConsole, ConsoleInfo.dwCursorPosition);
+
+ return temp;
+ }
+
+ return 0;
+}
+
+// This is for multi-character control strings (Paul Brannan 6/26/98)
+unsigned long TConsole::WriteCtrlString(const char *pszString, unsigned long cbString) {
+ unsigned long total = 0;
+ while(total < cbString) {
+ unsigned long Result = WriteCtrlChar(*(pszString + total));
+ if(Result == 0) {
+ Result = WriteStringFast(pszString + total, 1);
+ if(Result == 0) return total;
+ }
+ total += Result;
+ }
+ return total;
+}
+
+// This is for printing single control characters
+// WriteCtrlString uses this (Paul Brannan 6/26/98)
+unsigned long TConsole::WriteCtrlChar(char c) {
+ // The console does not handel the CR/LF chars as we might expect
+ // when using color. The attributes are not set correctly, so we
+ // must interpret them manualy to preserve the colors on the screen.
+
+ unsigned long Result = 0; // just in case (Paul Brannan 6/26/98)
+ switch (c) {
+ case '\x09': // horizontal tab
+ SetCursorPosition((((CON_CUR_X/8)+1)*8), CON_CUR_Y);
+ Result = 1;
+ break;
+
+ case '\x0a': // line feed
+ index();
+ Result = 1;
+ break;
+ case '\x0d': // carrage return
+ SetCursorPosition(CON_LEFT, CON_CUR_Y); // move to beginning of line
+ Result = 1;
+ break;
+ case '\b': // backspace
+ // Added support for backspace so the cursor position can be changed
+ // (Paul Brannan 5/25/98)
+ MoveCursorPosition(-1, 0);
+ Result = 1;
+ default : // else just write it like normal
+ break;
+ }
+
+ return Result;
+}
+
+void TConsole::index() {
+ // if on the last line scroll up
+ // This must work with scrolling (Paul Brannan 5/13/98)
+ if(iScrollEnd != -1 && (signed)CON_CUR_Y >= iScrollEnd) {
+ ScrollDown(iScrollStart, iScrollEnd, -1);
+ } else if ((iScrollEnd == -1 && (signed)CON_CUR_Y >= (signed)CON_HEIGHT)) {
+ DWORD Result;
+ WriteConsole(hConsole, "\n", 1, &Result, NULL);
+
+ // If we aren't at the bottom of the buffer, then we need to
+ // scroll down (Paul Brannan 4/14/2000)
+ if(iScrollEnd == -1 && ConsoleInfo.srWindow.Bottom < ConsoleInfo.dwSize.Y - 1) {
+ ConsoleInfo.srWindow.Top++;
+ ConsoleInfo.srWindow.Bottom++;
+ ConsoleInfo.dwCursorPosition.Y++;
+ // SetConsoleWindowInfo(hConsole, TRUE, &ConsoleInfo.srWindow);
+ } else {
+ ClearLine();
+ }
+ } else { // else move cursor down to the next line
+ SetCursorPosition(CON_CUR_X, CON_CUR_Y + 1);
+ }
+}
+
+void TConsole::reverse_index() {
+ // if on the top line scroll down
+ // This must work with scrolling (Paul Brannan 5/13/98)
+ // We should be comparing against iScrollStart, not iScrollEnd (PB 12/2/98)
+ if (iScrollStart == -1 && (signed)CON_CUR_Y <= 0) {
+ ScrollDown(iScrollStart, -1, 1);
+ } else if (iScrollStart != -1 && (signed)CON_CUR_Y <= iScrollStart) {
+ ScrollDown(iScrollStart, iScrollEnd, 1);
+ } else // else move cursor up to the previous line
+ SetCursorPosition(CON_CUR_X,CON_CUR_Y - 1);
+}
+
+void TConsole::ScrollDown( int iStartRow , int iEndRow, int bUp ){
+ CHAR_INFO ciChar;
+ SMALL_RECT srScrollWindow;
+
+ // Correction from I.Ioannou 11 May 1997
+ // check the scroll region
+ if (iStartRow < iScrollStart) iStartRow = iScrollStart;
+
+ // Correction from I.Ioannou 11 May 1997
+ // this will make Top the CON_TOP
+ if ( iStartRow == -1) iStartRow = 0;
+
+ // Correction from I.Ioannou 18 Aug 97
+ if ( iEndRow == -1) {
+ if ( iScrollEnd == -1 )
+ iEndRow = CON_HEIGHT;
+ else
+ iEndRow = ((CON_HEIGHT <= iScrollEnd) ? CON_HEIGHT : iScrollEnd);
+ }
+ //
+
+ if ( iStartRow > CON_HEIGHT) iStartRow = CON_HEIGHT;
+ if ( iEndRow > CON_HEIGHT) iEndRow = CON_HEIGHT;
+
+ srScrollWindow.Left = (CON_LEFT);
+ srScrollWindow.Right = (SHORT) (CON_RIGHT);
+ srScrollWindow.Top = (SHORT) (CON_TOP + iStartRow );
+ srScrollWindow.Bottom = (SHORT) (CON_TOP + iEndRow); // don't subtract 1 (PB 5/28)
+
+ ciChar.Char.AsciiChar = ' '; // fill with spaces
+ ciChar.Attributes = wAttributes; // fill with current attrib
+
+ // This should speed things up (Paul Brannan 9/2/98)
+ COORD dwDestOrg = {srScrollWindow.Left, srScrollWindow.Top + bUp};
+
+ // Note that iEndRow and iStartRow had better not be equal to -1 at this
+ // point. There are four cases to consider for out of bounds. Two of
+ // these cause the scroll window to be cleared; the others cause the
+ // scroll region to be modified. (Paul Brannan 12/3/98)
+ if(dwDestOrg.Y > CON_TOP + iEndRow) {
+ // We are scrolling past the end of the scroll region, so just
+ // clear the window instead (Paul Brannan 12/3/98)
+ ClearWindow(CON_TOP + iStartRow, CON_TOP + iEndRow);
+ return;
+ } else if(dwDestOrg.Y + (iEndRow-iStartRow+1) < CON_TOP + iStartRow) {
+ // We are scrolling past the end of the scroll region, so just
+ // clear the window instead (Paul Brannan 12/3/98)
+ ClearWindow(CON_TOP + iStartRow, CON_TOP + iEndRow);
+ return;
+ } else if(dwDestOrg.Y < CON_TOP + iStartRow) {
+ // Modify the scroll region (Paul Brannan 12/3/98)
+ dwDestOrg.Y = CON_TOP + iStartRow;
+ srScrollWindow.Top -= bUp;
+ } else if(dwDestOrg.Y + (iEndRow-iStartRow+1) > CON_TOP + iEndRow) {
+ // Modify the scroll region (Paul Brannan 12/3/98)
+ srScrollWindow.Bottom -= bUp;
+ }
+
+ ScrollConsoleScreenBuffer(hConsole, &srScrollWindow,
+ 0, dwDestOrg, &ciChar);
+}
+
+// This allows us to clear the screen with an arbitrary character
+// (Paul Brannan 6/26/98)
+void TConsole::ClearScreen(char c) {
+ DWORD dwWritten;
+ COORD Coord = {CON_LEFT, CON_TOP};
+ FillConsoleOutputCharacter(hConsole, c, (DWORD)(CON_COLS)*
+ (DWORD)(CON_LINES), Coord, &dwWritten);
+ FillConsoleOutputAttribute(hConsole, wAttributes, (DWORD)(CON_COLS)*
+ (DWORD)(CON_LINES), Coord, &dwWritten);
+}
+
+// Same as clear screen, but only affects the scroll region
+void TConsole::ClearWindow(int iStartRow, int iEndRow, char c) {
+ DWORD dwWritten;
+ COORD Coord = {CON_LEFT, CON_TOP + iStartRow};
+ FillConsoleOutputCharacter(hConsole, c, (DWORD)(CON_COLS)*
+ (DWORD)(iEndRow-iStartRow+1), Coord, &dwWritten);
+ FillConsoleOutputAttribute(hConsole, wAttributes, (DWORD)(CON_COLS)*
+ (DWORD)(CON_LINES), Coord, &dwWritten);
+}
+
+// Clear from cursor to end of screen
+void TConsole::ClearEOScreen(char c)
+{
+ DWORD dwWritten;
+ COORD Coord = {CON_LEFT, CON_TOP + CON_CUR_Y + 1};
+ FillConsoleOutputCharacter(hConsole, c, (DWORD)(CON_COLS)*
+ (DWORD)(CON_HEIGHT - CON_CUR_Y), Coord, &dwWritten);
+ FillConsoleOutputAttribute(hConsole, wAttributes, (DWORD)(CON_COLS)*
+ (DWORD)(CON_LINES - CON_CUR_Y), Coord, &dwWritten);
+ ClearEOLine();
+}
+
+// Clear from beginning of screen to cursor
+void TConsole::ClearBOScreen(char c)
+{
+ DWORD dwWritten;
+ COORD Coord = {CON_LEFT, CON_TOP};
+ FillConsoleOutputCharacter(hConsole, c, (DWORD)(CON_COLS)*
+ (DWORD)(CON_CUR_Y), Coord, &dwWritten);
+ FillConsoleOutputAttribute(hConsole, wAttributes, (DWORD)(CON_COLS)*
+ (DWORD)(CON_CUR_Y), Coord, &dwWritten);
+ ClearBOLine();
+}
+
+void TConsole::ClearLine(char c)
+{
+ DWORD dwWritten;
+ COORD Coord = {CON_LEFT, CON_TOP + CON_CUR_Y};
+ FillConsoleOutputCharacter(hConsole, c, (DWORD)(CON_COLS),
+ Coord, &dwWritten);
+ FillConsoleOutputAttribute(hConsole, wAttributes, (DWORD)(CON_COLS),
+ Coord, &dwWritten);
+ GetConsoleScreenBufferInfo(hConsole, &ConsoleInfo);
+}
+
+void TConsole::ClearEOLine(char c)
+{
+ DWORD dwWritten;
+ COORD Coord = {CON_LEFT + CON_CUR_X, CON_TOP + CON_CUR_Y};
+ FillConsoleOutputAttribute(hConsole, wAttributes,
+ (DWORD)(CON_RIGHT - CON_CUR_X) +1, Coord, &dwWritten);
+ FillConsoleOutputCharacter(hConsole, c, (DWORD)(CON_RIGHT - CON_CUR_X) +1,
+ Coord, &dwWritten);
+ GetConsoleScreenBufferInfo(hConsole, &ConsoleInfo);
+}
+
+void TConsole::ClearBOLine(char c)
+{
+ DWORD dwWritten;
+ COORD Coord = {CON_LEFT, CON_TOP + CON_CUR_Y};
+ FillConsoleOutputCharacter(hConsole, c, (DWORD)(CON_CUR_X) + 1, Coord,
+ &dwWritten);
+ FillConsoleOutputAttribute(hConsole, wAttributes, (DWORD)(CON_CUR_X) + 1,
+ Coord, &dwWritten);
+ GetConsoleScreenBufferInfo(hConsole, &ConsoleInfo);
+}
+
+
+// Inserts blank lines to the cursor-y-position
+// scrolls down the rest. CURSOR MOVEMENT (to Col#1) ???
+void TConsole::InsertLine(int numlines)
+{
+ COORD to;
+ SMALL_RECT from;
+ SMALL_RECT clip;
+ CHAR_INFO fill;
+ int acty;
+
+ // Rest of screen would be deleted
+ if ( (acty = GetCursorY()) >= CON_LINES - numlines ) {
+ ClearEOScreen(); // delete rest of screen
+ return;
+ } /* IF */
+
+ // Else scroll down the part of the screen which is below the
+ // cursor.
+ from.Left = CON_LEFT;
+ from.Top = CON_TOP + (SHORT)acty;
+ from.Right = CON_LEFT + (SHORT)CON_COLS;
+ from.Bottom = CON_TOP + (SHORT)CON_LINES;
+
+ clip = from;
+ to.X = 0;
+ to.Y = (SHORT)(from.Top + numlines);
+
+ fill.Char.AsciiChar = ' ';
+ fill.Attributes = 7; // WHICH ATTRIBUTES TO TAKE FOR BLANK LINE ??
+
+ ScrollConsoleScreenBuffer(hConsole, &from, &clip, to, &fill);
+} /* InsertLine */
+
+// Inserts blank characters under the cursor
+void TConsole::InsertCharacter(int numchar)
+{
+ int actx;
+ SMALL_RECT from;
+ SMALL_RECT clip;
+ COORD to;
+ CHAR_INFO fill;
+
+ if ( (actx = GetCursorX()) >= CON_COLS - numchar ) {
+ ClearEOLine();
+ return;
+ } /* IF */
+
+ from.Left = CON_LEFT + (SHORT)actx;
+ from.Top = CON_TOP + (SHORT)GetCursorY();
+ from.Right = CON_LEFT + (SHORT)CON_COLS;
+ from.Bottom = CON_TOP + (SHORT)from.Top;
+
+ clip = from;
+ to.X = (SHORT)(actx + numchar);
+ to.Y = from.Top;
+
+ fill.Char.AsciiChar = ' ';
+ fill.Attributes = wAttributes; // WHICH ATTRIBUTES TO TAKE FOR BLANK CHAR ??
+
+ ScrollConsoleScreenBuffer(hConsole, &from, &clip, to, &fill);
+} /* InsertCharacter */
+
+// Deletes characters under the cursor
+// Note that there are cases in which all the following lines should shift by
+// a character, but we don't handle these. This could break some
+// VT102-applications, but it shouldn't be too much of an issue.
+void TConsole::DeleteCharacter(int numchar)
+{
+ int actx;
+ SMALL_RECT from;
+ SMALL_RECT clip;
+ COORD to;
+ CHAR_INFO fill;
+
+ if ( (actx = GetCursorX()) >= CON_COLS - numchar ) {
+ ClearEOLine();
+ return;
+ } /* IF */
+
+ from.Left = CON_LEFT + (SHORT)actx;
+ from.Top = CON_TOP + (SHORT)GetCursorY();
+ from.Right = CON_LEFT + (SHORT)CON_COLS;
+ from.Bottom = CON_TOP + from.Top;
+
+ clip = from;
+ to.X = (SHORT)(actx - numchar);
+ to.Y = from.Top;
+
+ fill.Char.AsciiChar = ' ';
+ fill.Attributes = wAttributes; // WHICH ATTRIBUTES TO TAKE FOR BLANK CHAR ??
+
+ ScrollConsoleScreenBuffer(hConsole, &from, &clip, to, &fill);
+} /* DeleteCharacter */
+
+void TConsole::SetRawCursorPosition(int x, int y) {
+ if (x > CON_WIDTH) x = CON_WIDTH;
+ if (x < 0) x = 0;
+ if (y > CON_HEIGHT) y = CON_HEIGHT;
+ if (y < 0) y = 0;
+ COORD Coord = {(short)(CON_LEFT + x), (short)(CON_TOP + y)};
+ SetConsoleCursorPosition(hConsole, Coord);
+
+ // Update the ConsoleInfo struct (Paul Brannan 5/9/98)
+ ConsoleInfo.dwCursorPosition.Y = Coord.Y;
+ ConsoleInfo.dwCursorPosition.X = Coord.X;
+
+ // bug fix in case we went too far (Paul Brannan 5/25/98)
+ if(ConsoleInfo.dwCursorPosition.X < CON_LEFT)
+ ConsoleInfo.dwCursorPosition.X = CON_LEFT;
+ if(ConsoleInfo.dwCursorPosition.X > CON_RIGHT)
+ ConsoleInfo.dwCursorPosition.X = CON_RIGHT;
+ if(ConsoleInfo.dwCursorPosition.Y < CON_TOP)
+ ConsoleInfo.dwCursorPosition.Y = CON_TOP;
+ if(ConsoleInfo.dwCursorPosition.Y > CON_BOTTOM)
+ ConsoleInfo.dwCursorPosition.Y = CON_BOTTOM;
+}
+
+// The new SetCursorPosition takes scroll regions into consideration
+// (Paul Brannan 6/27/98)
+void TConsole::SetCursorPosition(int x, int y) {
+ if (x > CON_WIDTH) x = CON_WIDTH;
+ if (x < 0) x = 0;
+ if(iScrollEnd != -1) {
+ if(y > iScrollEnd) y = iScrollEnd;
+ } else {
+ if(y > CON_HEIGHT) y = CON_HEIGHT;
+ }
+ if(iScrollStart != -1) {
+ if(y < iScrollStart) y = iScrollStart;
+ } else {
+ if(y < 0) y = 0;
+ }
+
+ COORD Coord = {(short)(CON_LEFT + x), (short)(CON_TOP + y)};
+ SetConsoleCursorPosition(hConsole, Coord);
+
+ // Update the ConsoleInfo struct
+ ConsoleInfo.dwCursorPosition.Y = Coord.Y;
+ ConsoleInfo.dwCursorPosition.X = Coord.X;
+}
+
+void TConsole::MoveCursorPosition(int x, int y) {
+ SetCursorPosition(CON_CUR_X + x, CON_CUR_Y + y);
+}
+
+void TConsole::SetExtendedMode(int iFunction, BOOL bEnable)
+{
+ // Probably should do something here...
+ // Should change the screen mode, but do we need this?
+}
+
+void TConsole::SetScroll(int start, int end) {
+ iScrollStart = start;
+ iScrollEnd = end;
+}
+
+void TConsole::Beep() {
+ if(ini.get_do_beep()) {
+ if(!ini.get_speaker_beep()) printit("\a");
+ else ::Beep(400, 100);
+ }
+}
+
+void TConsole::SetCursorSize(int pct) {
+ CONSOLE_CURSOR_INFO ci = {(pct != 0)?pct:1, pct != 0};
+ SetConsoleCursorInfo(hConsole, &ci);
+}
+
+void saveScreen(CHAR_INFO *chiBuffer) {
+ HANDLE hStdout;
+ CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo;
+ SMALL_RECT srctReadRect;
+ COORD coordBufSize;
+ COORD coordBufCoord;
+
+ hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
+ GetConsoleScreenBufferInfo(hStdout, &ConsoleInfo);
+
+ srctReadRect.Top = CON_TOP; /* top left: row 0, col 0 */
+ srctReadRect.Left = CON_LEFT;
+ srctReadRect.Bottom = CON_BOTTOM; /* bot. right: row 1, col 79 */
+ srctReadRect.Right = CON_RIGHT;
+
+ coordBufSize.Y = CON_BOTTOM-CON_TOP+1;
+ coordBufSize.X = CON_RIGHT-CON_LEFT+1;
+
+ coordBufCoord.X = CON_TOP;
+ coordBufCoord.Y = CON_LEFT;
+
+ ReadConsoleOutput(
+ hStdout, /* screen buffer to read from */
+ chiBuffer, /* buffer to copy into */
+ coordBufSize, /* col-row size of chiBuffer */
+
+ coordBufCoord, /* top left dest. cell in chiBuffer */
+ &srctReadRect); /* screen buffer source rectangle */
+}
+
+void restoreScreen(CHAR_INFO *chiBuffer) {
+ HANDLE hStdout;
+ CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo;
+ SMALL_RECT srctReadRect;
+ COORD coordBufSize;
+ COORD coordBufCoord;
+
+ hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
+ GetConsoleScreenBufferInfo(hStdout, &ConsoleInfo);
+
+ // restore screen
+ srctReadRect.Top = CON_TOP; /* top left: row 0, col 0 */
+ srctReadRect.Left = CON_LEFT;
+ srctReadRect.Bottom = CON_BOTTOM; /* bot. right: row 1, col 79 */
+ srctReadRect.Right = CON_RIGHT;
+
+ coordBufSize.Y = CON_BOTTOM-CON_TOP+1;
+ coordBufSize.X = CON_RIGHT-CON_LEFT+1;
+
+ coordBufCoord.X = CON_TOP;
+ coordBufCoord.Y = CON_LEFT;
+ WriteConsoleOutput(
+ hStdout, /* screen buffer to write to */
+ chiBuffer, /* buffer to copy from */
+ coordBufSize, /* col-row size of chiBuffer */
+ coordBufCoord, /* top left src cell in chiBuffer */
+ &srctReadRect); /* dest. screen buffer rectangle */
+ // end restore screen
+
+}
+
+CHAR_INFO* newBuffer() {
[truncated at 1000 lines; 12 more skipped]
reactos/apps/utils/net/telnet/src
diff -N tconsole.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tconsole.h 21 Nov 2004 22:24:56 -0000 1.1
@@ -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
reactos/apps/utils/net/telnet/src
diff -N telnet.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ telnet.h 21 Nov 2004 22:24:56 -0000 1.1
@@ -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
+
reactos/apps/utils/net/telnet/src
diff -N tkeydef.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tkeydef.cpp 21 Nov 2004 22:24:56 -0000 1.1
@@ -0,0 +1,136 @@
+///////////////////////////////////////////////////////////////////////////////
+//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"
+#include <string.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
+
reactos/apps/utils/net/telnet/src
diff -N tkeydef.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tkeydef.h 21 Nov 2004 22:24:56 -0000 1.1
@@ -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
reactos/apps/utils/net/telnet/src
diff -N tkeymap.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tkeymap.cpp 21 Nov 2004 22:24:56 -0000 1.1
@@ -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() {
+};
reactos/apps/utils/net/telnet/src
diff -N tkeymap.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tkeymap.h 21 Nov 2004 22:24:56 -0000 1.1
@@ -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
reactos/apps/utils/net/telnet/src
diff -N tmapldr.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tmapldr.cpp 21 Nov 2004 22:24:56 -0000 1.1
@@ -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");
+ };
+};
reactos/apps/utils/net/telnet/src
diff -N tmapldr.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tmapldr.h 21 Nov 2004 22:24:56 -0000 1.1
@@ -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
reactos/apps/utils/net/telnet/src
diff -N tmouse.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tmouse.cpp 21 Nov 2004 22:24:56 -0000 1.1
@@ -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();
+}
reactos/apps/utils/net/telnet/src
diff -N tmouse.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tmouse.h 21 Nov 2004 22:24:56 -0000 1.1
@@ -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
reactos/apps/utils/net/telnet/src
diff -N tnclass.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tnclass.cpp 21 Nov 2004 22:24:56 -0000 1.1
@@ -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);
+}
+
reactos/apps/utils/net/telnet/src
diff -N tnclass.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tnclass.h 21 Nov 2004 22:24:56 -0000 1.1
@@ -0,0 +1,74 @@
+#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
+
reactos/apps/utils/net/telnet/src
diff -N tnclip.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tnclip.cpp 21 Nov 2004 22:24:56 -0000 1.1
@@ -0,0 +1,60 @@
+///////////////////////////////////////////////////////////////////////////////
+//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();
+}
+
reactos/apps/utils/net/telnet/src
diff -N tnclip.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tnclip.h 21 Nov 2004 22:24:56 -0000 1.1
@@ -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
reactos/apps/utils/net/telnet/src
diff -N tncon.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tncon.cpp 21 Nov 2004 22:24:56 -0000 1.1
@@ -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;
+ }
+}
reactos/apps/utils/net/telnet/src
diff -N tncon.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tncon.h 21 Nov 2004 22:24:56 -0000 1.1
@@ -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
reactos/apps/utils/net/telnet/src
diff -N tnconfig.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tnconfig.cpp 21 Nov 2004 22:24:56 -0000 1.1
@@ -0,0 +1,704 @@
+///////////////////////////////////////////////////////////////////////////////
+//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);
+}
+
reactos/apps/utils/net/telnet/src
diff -N tnconfig.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tnconfig.h 21 Nov 2004 22:24:56 -0000 1.1
@@ -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
reactos/apps/utils/net/telnet/src
diff -N tnerror.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tnerror.cpp 21 Nov 2004 22:24:56 -0000 1.1
@@ -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;
+
+}
+
reactos/apps/utils/net/telnet/src
diff -N tnerror.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tnerror.h 21 Nov 2004 22:24:56 -0000 1.1
@@ -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
reactos/apps/utils/net/telnet/src
diff -N tnetwork.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tnetwork.cpp 21 Nov 2004 22:24:56 -0000 1.1
@@ -0,0 +1,92 @@
+///////////////////////////////////////////////////////////////////////////////
+//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);
+}
+
reactos/apps/utils/net/telnet/src
diff -N tnetwork.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tnetwork.h 21 Nov 2004 22:24:56 -0000 1.1
@@ -0,0 +1,66 @@
+// 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> Removed for ReactOS
+#endif
+#else
+#include <winsock.h>
+#endif
+
+// ReactOS uses winsock2.h (Steven Edwards 12-31-01)
+#ifdef __REACTOS__
+#include <winsock2.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
reactos/apps/utils/net/telnet/src
diff -N tnmain.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tnmain.cpp 21 Nov 2004 22:24:56 -0000 1.1
@@ -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;
+}
reactos/apps/utils/net/telnet/src
diff -N tnmain.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tnmain.h 21 Nov 2004 22:24:56 -0000 1.1
@@ -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
reactos/apps/utils/net/telnet/src
diff -N tnmisc.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tnmisc.cpp 21 Nov 2004 22:24:56 -0000 1.1
@@ -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
+}
reactos/apps/utils/net/telnet/src
diff -N tnmisc.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tnmisc.h 21 Nov 2004 22:24:56 -0000 1.1
@@ -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
reactos/apps/utils/net/telnet/src
diff -N tnmsg.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tnmsg.h 21 Nov 2004 22:24:56 -0000 1.1
@@ -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
reactos/apps/utils/net/telnet/src
diff -N tparams.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tparams.h 21 Nov 2004 22:24:56 -0000 1.1
@@ -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
reactos/apps/utils/net/telnet/src
diff -N tparser.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tparser.h 21 Nov 2004 22:24:56 -0000 1.1
@@ -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
reactos/apps/utils/net/telnet/src
diff -N tscript.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tscript.cpp 21 Nov 2004 22:24:56 -0000 1.1
@@ -0,0 +1,63 @@
+///////////////////////////////////////////////////////////////////////////////
+//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");
+}
+
reactos/apps/utils/net/telnet/src
diff -N tscript.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tscript.h 21 Nov 2004 22:24:56 -0000 1.1
@@ -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
reactos/apps/utils/net/telnet/src
diff -N tscroll.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tscroll.cpp 21 Nov 2004 22:24:56 -0000 1.1
@@ -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;
+}
reactos/apps/utils/net/telnet/src
diff -N tscroll.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tscroll.h 21 Nov 2004 22:24:56 -0000 1.1
@@ -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
reactos/apps/utils/net/telnet/src
diff -N ttelhndl.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ttelhndl.cpp 21 Nov 2004 22:24:56 -0000 1.1
@@ -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;
+}
reactos/apps/utils/net/telnet/src
diff -N ttelhndl.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ttelhndl.h 21 Nov 2004 22:24:56 -0000 1.1
@@ -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
CVSspam 0.2.8