Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dan Theisen
tn5250
Commits
71bea97a
Commit
71bea97a
authored
Apr 29, 2002
by
Scott Klement
Browse files
Fixed garbage pixels at edge in Win32 terminal, and did some performance
tweaks in telnetstr.c & sslstream.c
parent
a3c082cd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
112 additions
and
56 deletions
+112
-56
ChangeLog
ChangeLog
+4
-0
src/sslstream.c
src/sslstream.c
+64
-29
src/telnetstr.c
src/telnetstr.c
+26
-12
win32/winterm.c
win32/winterm.c
+18
-15
No files found.
ChangeLog
View file @
71bea97a
2002-04-29 Scott Klement <klemscot@klements.com>
- Fixed garbage pixels at edge of screen in Win32 terminal
- Added some performance tweaks to telnetstr.c,sslstream.c
2002-04-18 Scott Klement <klemscot@klements.com>
- Applied old "Cursor Positioning" fix from Dave McKenzie from back in
Dec 2000. (Apparently it never got committed) Details are here:
...
...
src/sslstream.c
View file @
71bea97a
...
...
@@ -29,6 +29,7 @@
#include <openssl/ssl.h>
#include <openssl/err.h>
static
int
ssl_stream_get_next
(
Tn5250Stream
*
This
,
unsigned
char
*
buf
,
int
size
);
static
void
ssl_stream_do_verb
(
Tn5250Stream
*
This
,
unsigned
char
verb
,
unsigned
char
what
);
static
int
ssl_stream_host_verb
(
Tn5250Stream
*
This
,
unsigned
char
verb
,
unsigned
char
what
);
...
...
@@ -615,6 +616,55 @@ static void ssl_stream_destroy(Tn5250Stream *This)
if
(
This
->
userdata
!=
NULL
)
free
(
This
->
userdata
);
}
/****i* lib5250/ssl_stream_get_next
* NAME
* ssl_stream_get_next
* SYNOPSIS
* ssl_stream_get_next (This, buf, size);
* INPUTS
* Tn5250Stream * This -
* unsigned char * buf -
* int size -
* DESCRIPTION
* Reads data from the socket, returns the length,
* or -2 if disconnected, or -1 if out of data to read.
*****/
static
int
ssl_stream_get_next
(
Tn5250Stream
*
This
,
unsigned
char
*
buf
,
int
size
)
{
int
rc
;
fd_set
wrwait
;
/* read data.
*
* Note: it's possible, due to the negotiations that SSL can do below
* the surface, that SSL_read() will need to wait for buffer space
* to write to. If that happens, we'll use select() to wait for
* space and try again.
*/
do
{
rc
=
SSL_read
(
This
->
ssl_handle
,
buf
,
size
);
if
(
rc
<
1
)
{
errnum
=
SSL_get_error
(
This
->
ssl_handle
,
rc
);
switch
(
errnum
)
{
case
SSL_ERROR_WANT_WRITE
:
FD_ZERO
(
&
wrwait
);
FD_SET
(
This
->
sockfd
,
&
wrwait
);
select
(
This
->
sockfd
+
1
,
NULL
,
&
wrwait
,
NULL
,
NULL
);
break
;
case
SSL_ERROR_WANT_READ
:
return
-
1
;
break
;
default:
return
-
2
;
break
;
}
}
}
while
(
rc
<
1
);
return
rc
;
}
static
int
ssl_sendWill
(
Tn5250Stream
*
This
,
unsigned
char
what
)
{
static
UCHAR
buff
[
3
]
=
{
IAC
,
WILL
};
...
...
@@ -936,43 +986,27 @@ static void ssl_stream_sb(Tn5250Stream * This, unsigned char *sb_buf, int sb_len
* is waiting on the socket or -2 if disconnected, or -END_OF_RECORD if a
* telnet EOR escape sequence was encountered.
*****/
#define TN5250_RBSIZE 8192
static
int
ssl_stream_get_byte
(
Tn5250Stream
*
This
)
{
unsigned
char
temp
;
int
rc
;
unsigned
char
verb
;
fd_set
wrwait
;
static
unsigned
char
rcvbuf
[
TN5250_RBSIZE
];
static
int
rcvbufpos
=
0
;
static
int
rcvbuflen
=
-
1
;
do
{
if
(
This
->
state
==
TN5250_STREAM_STATE_NO_DATA
)
This
->
state
=
TN5250_STREAM_STATE_DATA
;
/* read data.
*
* Note: it's possible, due to the negotiations that SSL can do below
* the surface, that SSL_read() will need to wait for buffer space
* to write to. If that happens, we'll use select() to wait for
* space and try again.
*/
do
{
rc
=
SSL_read
(
This
->
ssl_handle
,
&
temp
,
1
);
if
(
rc
<
1
)
{
errnum
=
SSL_get_error
(
This
->
ssl_handle
,
rc
);
switch
(
errnum
)
{
case
SSL_ERROR_WANT_WRITE
:
FD_ZERO
(
&
wrwait
);
FD_SET
(
This
->
sockfd
,
&
wrwait
);
select
(
This
->
sockfd
+
1
,
NULL
,
&
wrwait
,
NULL
,
NULL
);
break
;
case
SSL_ERROR_WANT_READ
:
return
-
1
;
break
;
default:
return
-
2
;
break
;
}
}
}
while
(
rc
<
1
);
rcvbufpos
++
;
if
(
rcvbufpos
>=
rcvbuflen
)
{
rcvbufpos
=
0
;
rcvbuflen
=
ssl_stream_get_next
(
This
,
rcvbuf
,
TN5250_RBSIZE
);
if
(
rcvbuflen
<
0
)
return
rcvbuflen
;
}
temp
=
rcvbuf
[
rcvbufpos
];
switch
(
This
->
state
)
{
case
TN5250_STREAM_STATE_DATA
:
...
...
@@ -1217,7 +1251,8 @@ int ssl_stream_handle_receive(Tn5250Stream * This)
if
(
c
==
-
END_OF_RECORD
&&
This
->
current_record
!=
NULL
)
{
/* End of current packet. */
tn5250_record_dump
(
This
->
current_record
);
if
(
tn5250_logfile
!=
NULL
)
tn5250_record_dump
(
This
->
current_record
);
This
->
records
=
tn5250_record_list_add
(
This
->
records
,
This
->
current_record
);
This
->
current_record
=
NULL
;
This
->
record_count
++
;
...
...
src/telnetstr.c
View file @
71bea97a
...
...
@@ -21,7 +21,7 @@
*/
#include "tn5250-private.h"
static
int
telnet_stream_get_next
(
Tn5250Stream
*
This
);
static
int
telnet_stream_get_next
(
Tn5250Stream
*
This
,
unsigned
char
*
buf
,
int
size
);
static
void
telnet_stream_do_verb
(
Tn5250Stream
*
This
,
unsigned
char
verb
,
unsigned
char
what
);
static
int
telnet_stream_host_verb
(
Tn5250Stream
*
This
,
unsigned
char
verb
,
unsigned
char
what
);
...
...
@@ -473,14 +473,17 @@ static void telnet_stream_destroy(Tn5250Stream *This)
* NAME
* telnet_stream_get_next
* SYNOPSIS
* ret = telnet_stream_get_next (This);
* ret = telnet_stream_get_next (This
, buf, size
);
* INPUTS
* Tn5250Stream * This -
* unsigned char * buf -
* int size -
* DESCRIPTION
* Gets the next byte from the socket or returns -1 if no data is
* currently available on the socket or -2 if we have been disconnected.
* Gets the next buffer of data from the socket. The
* return value is the length of the data received,
* or -1 for no data to receive, or -2 if disconnected
*****/
static
int
telnet_stream_get_next
(
Tn5250Stream
*
This
)
static
int
telnet_stream_get_next
(
Tn5250Stream
*
This
,
unsigned
char
*
buf
,
int
size
)
{
unsigned
char
curchar
;
int
rc
;
...
...
@@ -495,10 +498,10 @@ static int telnet_stream_get_next(Tn5250Stream * This)
if
(
!
FD_ISSET
(
This
->
sockfd
,
&
fdr
))
return
-
1
;
/* No data on socket. */
rc
=
TN_RECV
(
This
->
sockfd
,
(
char
*
)
&
curchar
,
1
,
0
);
rc
=
TN_RECV
(
This
->
sockfd
,
buf
,
size
,
0
);
if
(
WAS_ERROR_RET
(
rc
))
{
if
(
LAST_ERROR
!=
ERR_AGAIN
&&
LAST_ERROR
!=
ERR_INTR
)
{
printf
(
"Error reading from socket: %s
\n
"
,
strerror
(
LAST_ERROR
));
TN5250_LOG
(
(
"Error reading from socket: %s
\n
"
,
strerror
(
LAST_ERROR
))
)
;
return
-
2
;
}
else
return
-
1
;
...
...
@@ -508,7 +511,7 @@ static int telnet_stream_get_next(Tn5250Stream * This)
if
(
rc
==
0
)
return
-
2
;
return
(
int
)
curcha
r
;
return
r
c
;
}
static
int
sendWill
(
SOCKET_TYPE
sock
,
unsigned
char
what
)
...
...
@@ -822,18 +825,28 @@ static void telnet_stream_sb(Tn5250Stream * This, unsigned char *sb_buf, int sb_
* is waiting on the socket or -2 if disconnected, or -END_OF_RECORD if a
* telnet EOR escape sequence was encountered.
*****/
#define TN5250_RBSIZE 8192
static
int
telnet_stream_get_byte
(
Tn5250Stream
*
This
)
{
int
temp
;
unsigned
char
verb
;
static
unsigned
char
rcvbuf
[
TN5250_RBSIZE
];
static
int
rcvbufpos
=
0
;
static
int
rcvbuflen
=
-
1
;
do
{
if
(
This
->
state
==
TN5250_STREAM_STATE_NO_DATA
)
This
->
state
=
TN5250_STREAM_STATE_DATA
;
temp
=
telnet_stream_get_next
(
This
);
if
(
temp
<
0
)
return
temp
;
rcvbufpos
++
;
if
(
rcvbufpos
>=
rcvbuflen
)
{
rcvbufpos
=
0
;
rcvbuflen
=
telnet_stream_get_next
(
This
,
rcvbuf
,
TN5250_RBSIZE
);
if
(
rcvbuflen
<
0
)
return
rcvbuflen
;
}
temp
=
rcvbuf
[
rcvbufpos
];
switch
(
This
->
state
)
{
case
TN5250_STREAM_STATE_DATA
:
...
...
@@ -1089,7 +1102,8 @@ int telnet_stream_handle_receive(Tn5250Stream * This)
if
(
c
==
-
END_OF_RECORD
&&
This
->
current_record
!=
NULL
)
{
/* End of current packet. */
tn5250_record_dump
(
This
->
current_record
);
if
(
tn5250_logfile
!=
NULL
)
tn5250_record_dump
(
This
->
current_record
);
This
->
records
=
tn5250_record_list_add
(
This
->
records
,
This
->
current_record
);
This
->
current_record
=
NULL
;
This
->
record_count
++
;
...
...
win32/winterm.c
View file @
71bea97a
...
...
@@ -152,7 +152,8 @@ static int win32_terminal_set_config(Tn5250Terminal *This, Tn5250Config *conf);
static
int
win32_terminal_waitevent
(
Tn5250Terminal
*
This
);
static
int
win32_terminal_getkey
(
Tn5250Terminal
*
This
);
void
win32_terminal_queuekey
(
HWND
hwnd
,
Tn5250Terminal
*
This
,
int
key
);
void
win32_terminal_clear_screenbuf
(
HWND
hwnd
,
int
width
,
int
height
,
int
delet
);
void
win32_terminal_clear_screenbuf
(
HWND
hwnd
,
int
width
,
int
height
,
int
delet
,
int
mknew
);
void
tn5250_win32_set_beep
(
Tn5250Terminal
*
This
,
const
char
*
beepfile
);
void
tn5250_win32_terminal_display_ruler
(
Tn5250Terminal
*
This
,
int
f
);
static
void
win32_terminal_beep
(
Tn5250Terminal
*
This
);
...
...
@@ -621,7 +622,7 @@ static void win32_terminal_init(Tn5250Terminal * This)
width
=
(
rect
.
right
-
rect
.
left
)
+
1
;
height
=
(
rect
.
bottom
-
rect
.
top
)
+
1
;
bmphdc
=
CreateCompatibleDC
(
NULL
);
win32_terminal_clear_screenbuf
(
This
->
data
->
hwndMain
,
width
,
height
,
0
);
win32_terminal_clear_screenbuf
(
This
->
data
->
hwndMain
,
width
,
height
,
0
,
1
);
tn5250_win32_init_fonts
(
This
,
tn5250_config_get
(
This
->
data
->
config
,
"font_80"
),
...
...
@@ -1134,11 +1135,8 @@ static void win32_terminal_update(Tn5250Terminal * This, Tn5250Display *display)
/* clear the screen buffer (one big black rectangle) */
GetClientRect
(
This
->
data
->
hwndMain
,
&
cr
);
oldbrush
=
SelectObject
(
bmphdc
,
background_brush
);
oldpen
=
SelectObject
(
bmphdc
,
GetStockObject
(
BLACK_PEN
));
Rectangle
(
bmphdc
,
cr
.
left
,
cr
.
top
,
cr
.
right
,
cr
.
bottom
);
SelectObject
(
bmphdc
,
oldbrush
);
SelectObject
(
bmphdc
,
oldpen
);
win32_terminal_clear_screenbuf
(
This
->
data
->
hwndMain
,
cr
.
right
+
1
,
cr
.
bottom
+
1
,
0
,
0
);
if
(
This
->
data
->
resized
||
This
->
data
->
last_height
!=
tn5250_display_height
(
display
)
||
...
...
@@ -1625,7 +1623,8 @@ void win32_terminal_queuekey(HWND hwnd, Tn5250Terminal *This, int key) {
* DESCRIPTION
* Create/Resize the bitmap that we use as the screen buffer.
*****/
void
win32_terminal_clear_screenbuf
(
HWND
hwnd
,
int
width
,
int
height
,
int
delet
)
{
void
win32_terminal_clear_screenbuf
(
HWND
hwnd
,
int
width
,
int
height
,
int
delet
,
int
mknew
)
{
HDC
hdc
;
HBRUSH
oldbrush
;
...
...
@@ -1634,16 +1633,20 @@ void win32_terminal_clear_screenbuf(HWND hwnd,int width,int height,int delet) {
if
(
delet
)
DeleteObject
(
screenbuf
);
hdc
=
GetDC
(
hwnd
);
screenbuf
=
CreateCompatibleBitmap
(
hdc
,
width
,
height
);
ReleaseDC
(
hwnd
,
hdc
);
if
(
mknew
)
{
hdc
=
GetDC
(
hwnd
);
screenbuf
=
CreateCompatibleBitmap
(
hdc
,
width
,
height
);
ReleaseDC
(
hwnd
,
hdc
);
}
SelectObject
(
bmphdc
,
screenbuf
);
oldbrush
=
SelectObject
(
bmphdc
,
background_brush
);
oldpen
=
SelectObject
(
bmphdc
,
GetStockObject
(
BLACK_PEN
));
Rectangle
(
bmphdc
,
0
,
0
,
width
-
1
,
height
-
1
);
oldpen
=
SelectObject
(
bmphdc
,
CreatePen
(
PS_SOLID
,
0
,
colorlist
[
A_5250_BLACK
].
ref
));
Rectangle
(
bmphdc
,
0
,
0
,
width
+
3
,
height
+
3
);
SelectObject
(
bmphdc
,
oldbrush
);
SelectObject
(
bmphdc
,
oldpen
);
oldpen
=
SelectObject
(
bmphdc
,
oldpen
);
DeleteObject
(
oldpen
);
return
;
}
...
...
@@ -1764,7 +1767,7 @@ win32_terminal_wndproc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
globTerm
->
data
->
maximized
=
0
;
if
(
h
>
0
&&
w
>
0
)
{
int
c
,
r
;
win32_terminal_clear_screenbuf
(
hwnd
,
w
,
h
,
1
);
win32_terminal_clear_screenbuf
(
hwnd
,
w
,
h
,
1
,
1
);
if
(
globTerm
!=
NULL
&&
globDisplay
!=
NULL
)
{
if
(
globTerm
->
data
->
resize_fonts
)
{
win32_calc_default_font_size
(
hwnd
,
80
,
24
,
&
c
,
&
r
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment