Commit 16c31b2e authored by Jason 'Eraserhead' Felice's avatar Jason 'Eraserhead' Felice
Browse files

Lots of bugs fixed, lib5250 documentation comments (for Robodoc) added, TD and...

Lots of bugs fixed, lib5250 documentation comments (for Robodoc) added, TD and MC orders implemented, as well as Read Immediate Alternate and Read MDT Fields Alternate commands.
parent a56218fb
2000-01-07 Jay 'Eraserhead' Felcie <jasonf@nacs.net>
2000-01-11 Jay 'Eraserhead' Felice <jasonf@nacs.net>
- Reported by Phil Gregory - display is not inhibited and cursor is not in
proper place after Write Error Code.
- Implemented Read Immediate Alternate and Read MDT Fields Alternate commands,
modified tn5250_session_query_reply to indicate that we now support them to
the host.
- Implemented TD (Transparent Data) order. There is apparently nowhere to
indicate this to the host. (This may have been the cause of earlier binary
data issues).
- Implemented MC (Move Cursor) order. This is now indicated to the host.
- Move remaining keyboard handling from session.c to display.c, make
tn5250_display_waitevent NOT return keyboard events. (Might we want to
pass along ones we don't understand? Nah...)
- Save/restore message line when Write Error Code is used by the host to
inhibit display. Also, use the correct message line (according to the
format table header).
- Added refresh() call to cursesterm.c. Hopefully, this will resolve the
80 -> 132 column switch refresh issues reported by some users.
- Wrote a quick hack of a Perl script to insert Robodoc comment headers
for all the functions (and manually did all the structures). Yeah, it's
ugly, but no-one produces a tool as good as Javadoc which works on C.
2000-01-07 Jay 'Eraserhead' Felice <jasonf@nacs.net>
- tn5250_dbuffer_send_data_for_fields(): A *SET* bit inhibits the transmission
of field data, not a clear one. Also, fine point of spec, all three aid key
......
......@@ -2,7 +2,7 @@ dnl ** Process this file with autoconf to produce a configure script.
AC_INIT(src/tn5250.c)
dnl ** Automake Intialization
AM_INIT_AUTOMAKE(tn5250, 0.15.5)
AM_INIT_AUTOMAKE(tn5250, 0.15.6)
AM_CONFIG_HEADER(src/tn5250-config.h)
dnl ** Checks for programs.
......@@ -112,6 +112,7 @@ AC_CHECK_HEADERS(netinet/in.h)
dnl ** If you ain't using windows, this is true.
AC_DEFINE(SOCKET_TYPE,int)
AC_TYPE_SIGNAL
dnl ** Checks for library functions.
AC_FUNC_MEMCMP
......
......@@ -2,5 +2,50 @@
man_MANS = scs2ascii.1\
tn5250.1
EXTRA_DIST = $(man_MANS)
#
# These are documentation of the lib5250 API
#
HTMLDOCS = buffer.c.html\
buffer.h.html\
codes5250.h.html\
config.h.html\
cursesterm.c.html\
cursesterm.h.html\
dbuffer.c.html\
dbuffer.h.html\
debug.c.html\
debug.h.html\
display.c.html\
display.h.html\
field.c.html\
field.h.html\
index.html\
printsession.c.html\
printsession.h.html\
record.c.html\
record.h.html\
scs.h.html\
session.c.html\
session.h.html\
slangterm.c.html\
slangterm.h.html\
stream.c.html\
stream.h.html\
telnetstr.c.html\
terminal.h.html\
transmaps.h.html\
utility.c.html\
utility.h.html\
version.c.html\
wtd.c.html\
wtd.h.html
#
# This means 'make dist' and 'make distcheck' won't work if you
# don't have robodoc installed (oh, well).
#
EXTRA_DIST = $(man_MANS)\
$(HTMLDOCS)
$(addprefix $(top_srcdir),$(HTMLDOCS)): $(top_srcdir)/src/*.c $(top_srcdir)/src/*.h
$(MAKE) -C ../src docs
......@@ -65,4 +65,24 @@ lclint:
config.h: tn5250-config.h
cat tn5250-config.h |sed -e 's/VERSION/TN5250_LIB_VERSION/g' -e '/PACKAGE/d' >config.h
#
# We generate our library docs using robodoc.
#
DOCFILES = $(lib5250_la_SOURCES) $(pkginclude_HEADERS)
docs:
( rm -f index.xrefs ; \
for file in $(DOCFILES) ; do \
robodoc $$file ../doc/$$file.html GENXREF ../doc/$$file.xref ; \
echo "../doc/$$file.xref" >>../doc/index.xrefs ; \
done ; \
for file in $(DOCFILES) ; do \
robodoc $$file ../doc/$$file.html HTML -x ../doc/index.xrefs ; \
done ; \
robodoc ../doc/index.xrefs ../doc/index.html INDEX ; \
rm -f ../doc/*.xref ../doc/index.xrefs )
clean-local:
rm -f $(DOCFILES) *.xref index.xrefs index.html
.PHONY: lclint
......@@ -26,12 +26,32 @@
#define BUFFER_DELTA 128
/****f* lib5250/tn5250_buffer_init
* NAME
* tn5250_buffer_init
* SYNOPSIS
* tn5250_buffer_init (&buf);
* INPUTS
* Tn5250Buffer * buf - Pointer to a Tn5250Buffer object.
* DESCRIPTION
* Zeros internal members.
*****/
void tn5250_buffer_init(Tn5250Buffer * This)
{
This->len = This->allocated = 0;
This->data = NULL;
}
/****f* lib5250/tn5250_buffer_free
* NAME
* tn5250_buffer_free
* SYNOPSIS
* tn5250_buffer_free (&buf);
* INPUTS
* Tn5250Buffer * buf - Pointer to a buffer object.
* DESCRIPTION
* Frees variable-length data and zeros internal members.
*****/
void tn5250_buffer_free(Tn5250Buffer * This)
{
if (This->data != NULL)
......@@ -40,6 +60,19 @@ void tn5250_buffer_free(Tn5250Buffer * This)
This->len = This->allocated = 0;
}
/****f* lib5250/tn5250_buffer_append_byte
* NAME
* tn5250_buffer_append_byte
* SYNOPSIS
* tn5250_buffer_append_byte (&buf, byte);
* INPUTS
* Tn5250Buffer * buf - Pointer to a buffer object.
* unsigned char byte - The byte to append.
* DESCRIPTION
* Appends a single byte to the end of the variable-length data
* and reallocates the buffer if necessary to accomodate the new
* byte.
*****/
void tn5250_buffer_append_byte(Tn5250Buffer * This, unsigned char b)
{
if (This->len + 1 >= This->allocated) {
......@@ -55,12 +88,39 @@ void tn5250_buffer_append_byte(Tn5250Buffer * This, unsigned char b)
This->data[This->len++] = b;
}
/****f* lib5250/tn5250_buffer_append_data
* NAME
* tn5250_buffer_append_data
* SYNOPSIS
* tn5250_buffer_append_data (&buf, data, len);
* INPUTS
* Tn5250Buffer * buf - Pointer to a buffer object.
* unsigned char * data - Data to append.
* int len - Length of data to append.
* DESCRIPTION
* Appends a variable number of bytes to the end of the variable-length
* data and reallocates the buffer if necessary to accomodate the new
* data.
*****/
void tn5250_buffer_append_data(Tn5250Buffer * This, unsigned char *data, int len)
{
while (len--)
tn5250_buffer_append_byte(This, *data++);
}
/****f* lib5250/tn5250_buffer_log
* NAME
* tn5250_buffer_log
* SYNOPSIS
* tn5250_buffer_log (&buf,"> ");
* INPUTS
* Tn5250Buffer * buf - Pointer to a buffer object.
* const char * prefix - Character string to prefix dump lines
* with in log.
* DESCRIPTION
* Dumps the contents of the buffer to the 5250 logfile, if one is
* currently open.
*****/
void tn5250_buffer_log(Tn5250Buffer * This, const char *prefix)
{
int pos;
......
......@@ -22,28 +22,45 @@
extern "C" {
#endif
struct _Tn5250Buffer {
unsigned char /*@null@*/ *data;
int len;
int allocated;
};
/****s* lib5250/Tn5250Buffer
* NAME
* Tn5250Buffer
* SYNOPSIS
* Tn5250Buffer buf;
* tn5250_buffer_init(&buf);
* tn5250_buffer_append_byte(&buf, '\n');
* tn5250_buffer_append_data(&buf, data, len);
* fwrite(file,tn5250_buffer_data(&buf),1,tn5250_buffer_length(&buf));
* tn5250_buffer_free(&buf);
* DESCRIPTION
* A dynamically-sizing buffer of bytes.
* SOURCE
*/
struct _Tn5250Buffer {
unsigned char /*@null@*/ *data;
int len;
int allocated;
};
typedef /*@abstract@*/ /*@immutable@*/ struct _Tn5250Buffer Tn5250Buffer;
typedef /*@abstract@*/ /*@immutable@*/ struct _Tn5250Buffer Tn5250Buffer;
/*******/
/* These don't work like new/destroy */
extern void tn5250_buffer_init( /*@out@*/ Tn5250Buffer * This);
extern void tn5250_buffer_free(Tn5250Buffer * This);
extern void tn5250_buffer_init( /*@out@*/ Tn5250Buffer * This);
extern void tn5250_buffer_free(Tn5250Buffer * This);
#define tn5250_buffer_data(This) \
((This)->data ? (This)->data : (unsigned char *)"")
#define tn5250_buffer_length(This) ((This)->len)
extern void tn5250_buffer_append_byte(Tn5250Buffer * This, unsigned char b);
extern void tn5250_buffer_append_data(Tn5250Buffer * This, unsigned char *data, int len);
extern void tn5250_buffer_log (Tn5250Buffer *This, const char *prefix);
extern void tn5250_buffer_append_byte(Tn5250Buffer * This, unsigned char b);
extern void tn5250_buffer_append_data(Tn5250Buffer * This, unsigned char *data, int len);
extern void tn5250_buffer_log (Tn5250Buffer *This, const char *prefix);
#ifdef __cplusplus
}
#endif
#endif /* BUFFER_H */
/* vi:set sts=3 sw=3 autoindent: */
......@@ -22,9 +22,8 @@ extern "C" {
#define CMD_WRITE_ERROR_CODE 0x21
#define CMD_READ_INPUT_FIELDS 0x42
#define CMD_ROLL 0x23
#define CMD_READ_MDT_FIELDS_ALT 0x82 /* FIXME: */
#define CMD_READ_MDT_FIELDS_IMMEDIATE_ALT 0x83 /* FIXME: */
#define CMD_READ_MDT_FIELDS_ALT 0x82
#define CMD_READ_IMMEDIATE_ALT 0x83
/* Orders - those tagged FIXME are not implemented: */
#define SOH 0x01 /* Start of header */
......
......@@ -15,7 +15,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "tn5250-config.h"
#ifdef USE_CURSES
......@@ -117,9 +116,16 @@ struct _Tn5250TerminalPrivate {
int is_xterm;
};
/*
/****f* lib5250/tn5250_curses_terminal_new
* NAME
* tn5250_curses_terminal_new
* SYNOPSIS
* ret = tn5250_curses_terminal_new ();
* INPUTS
* None
* DESCRIPTION
* Create a new curses terminal object.
*/
*****/
Tn5250Terminal *tn5250_curses_terminal_new()
{
Tn5250Terminal *r = tn5250_new(Tn5250Terminal, 1);
......@@ -154,6 +160,16 @@ Tn5250Terminal *tn5250_curses_terminal_new()
return r;
}
/****i* lib5250/curses_terminal_init
* NAME
* curses_terminal_init
* SYNOPSIS
* curses_terminal_init (This);
* INPUTS
* Tn5250Terminal * This -
* DESCRIPTION
* DOCUMENT ME!!!
*****/
static void curses_terminal_init(Tn5250Terminal * This)
{
char buf[6];
......@@ -199,11 +215,31 @@ static void curses_terminal_init(Tn5250Terminal * This)
This->data->quit_flag = 0;
}
/****i* lib5250/curses_terminal_term
* NAME
* curses_terminal_term
* SYNOPSIS
* curses_terminal_term (This);
* INPUTS
* Tn5250Terminal * This -
* DESCRIPTION
* DOCUMENT ME!!!
*****/
static void curses_terminal_term(Tn5250Terminal /*@unused@*/ * This)
{
endwin();
}
/****i* lib5250/curses_terminal_destroy
* NAME
* curses_terminal_destroy
* SYNOPSIS
* curses_terminal_destroy (This);
* INPUTS
* Tn5250Terminal * This -
* DESCRIPTION
* DOCUMENT ME!!!
*****/
static void curses_terminal_destroy(Tn5250Terminal * This)
{
if (This->data != NULL)
......@@ -211,6 +247,16 @@ static void curses_terminal_destroy(Tn5250Terminal * This)
free(This);
}
/****i* lib5250/curses_terminal_width
* NAME
* curses_terminal_width
* SYNOPSIS
* ret = curses_terminal_width (This);
* INPUTS
* Tn5250Terminal * This -
* DESCRIPTION
* DOCUMENT ME!!!
*****/
static int curses_terminal_width(Tn5250Terminal /*@unused@*/ * This)
{
int y, x;
......@@ -218,6 +264,16 @@ static int curses_terminal_width(Tn5250Terminal /*@unused@*/ * This)
return x + 1;
}
/****i* lib5250/curses_terminal_height
* NAME
* curses_terminal_height
* SYNOPSIS
* ret = curses_terminal_height (This);
* INPUTS
* Tn5250Terminal * This -
* DESCRIPTION
* DOCUMENT ME!!!
*****/
static int curses_terminal_height(Tn5250Terminal /*@unused@*/ * This)
{
int y, x;
......@@ -225,6 +281,16 @@ static int curses_terminal_height(Tn5250Terminal /*@unused@*/ * This)
return y + 1;
}
/****i* lib5250/curses_terminal_flags
* NAME
* curses_terminal_flags
* SYNOPSIS
* ret = curses_terminal_flags (This);
* INPUTS
* Tn5250Terminal * This -
* DESCRIPTION
* DOCUMENT ME!!!
*****/
static int curses_terminal_flags(Tn5250Terminal /*@unused@*/ * This)
{
int f = 0;
......@@ -233,6 +299,17 @@ static int curses_terminal_flags(Tn5250Terminal /*@unused@*/ * This)
return f;
}
/****i* lib5250/curses_terminal_update
* NAME
* curses_terminal_update
* SYNOPSIS
* curses_terminal_update (This, display);
* INPUTS
* Tn5250Terminal * This -
* Tn5250Display * display -
* DESCRIPTION
* DOCUMENT ME!!!
*****/
static void curses_terminal_update(Tn5250Terminal * This, Tn5250Display *display)
{
int my, mx;
......@@ -244,7 +321,6 @@ static void curses_terminal_update(Tn5250Terminal * This, Tn5250Display *display
|| This->data->last_height != tn5250_display_height(display)) {
clear();
if(This->data->is_xterm) {
refresh ();
printf ("\x1b[8;%d;%dt", tn5250_display_height (display)+1,
tn5250_display_width (display));
fflush (stdout);
......@@ -254,6 +330,7 @@ static void curses_terminal_update(Tn5250Terminal * This, Tn5250Display *display
/* Make sure we get a SIGWINCH - We need curses to resize its
* buffer. */
raise (SIGWINCH);
refresh ();
}
This->data->last_width = tn5250_display_width(display);
This->data->last_height = tn5250_display_height(display);
......@@ -305,6 +382,17 @@ static void curses_terminal_update(Tn5250Terminal * This, Tn5250Display *display
refresh();
}
/****i* lib5250/curses_terminal_update_indicators
* NAME
* curses_terminal_update_indicators
* SYNOPSIS
* curses_terminal_update_indicators (This, display);
* INPUTS
* Tn5250Terminal * This -
* Tn5250Display * display -
* DESCRIPTION
* DOCUMENT ME!!!
*****/
static void curses_terminal_update_indicators(Tn5250Terminal /*@unused@*/ * This, Tn5250Display *display)
{
int inds = tn5250_display_indicators(display);
......@@ -332,6 +420,16 @@ static void curses_terminal_update_indicators(Tn5250Terminal /*@unused@*/ * This
refresh();
}
/****i* lib5250/curses_terminal_waitevent
* NAME
* curses_terminal_waitevent
* SYNOPSIS
* ret = curses_terminal_waitevent (This);
* INPUTS
* Tn5250Terminal * This -
* DESCRIPTION
* DOCUMENT ME!!!
*****/
static int curses_terminal_waitevent(Tn5250Terminal * This)
{
fd_set fdr;
......@@ -361,6 +459,16 @@ static int curses_terminal_waitevent(Tn5250Terminal * This)
return result;
}
/****i* lib5250/curses_terminal_getkey
* NAME
* curses_terminal_getkey
* SYNOPSIS
* ret = curses_terminal_getkey (This);
* INPUTS
* Tn5250Terminal * This -
* DESCRIPTION
* DOCUMENT ME!!!
*****/
static int curses_terminal_getkey(Tn5250Terminal * This)
{
int key = getch();
......@@ -445,6 +553,16 @@ static int curses_terminal_getkey(Tn5250Terminal * This)
}
}
/****i* lib5250/curses_terminal_beep
* NAME
* curses_terminal_beep
* SYNOPSIS
* curses_terminal_beep (This);
* INPUTS
* Tn5250Terminal * This -
* DESCRIPTION
* DOCUMENT ME!!!
*****/
static void curses_terminal_beep (Tn5250Terminal *This)
{
TN5250_LOG (("CURSES: beep\n"));
......@@ -452,12 +570,19 @@ static void curses_terminal_beep (Tn5250Terminal *This)
refresh ();
}
/*
/****i* lib5250/curses_terminal_get_esc_key
* NAME
* curses_terminal_get_esc_key
* SYNOPSIS
* ret = curses_terminal_get_esc_key (This, is_esc);
* INPUTS
* Tn5250Terminal * This -
* int is_esc -
* DESCRIPTION
* If a vt100 escape key sequence was introduced (using either
* <Esc> or <Ctrl+g>), handle the next key in the sequence.
*/
static int curses_terminal_get_esc_key(Tn5250Terminal * This,
int is_esc)
* <Esc> or <Ctrl+g>), handle the next key in the sequence.
*****/
static int curses_terminal_get_esc_key(Tn5250Terminal * This, int is_esc)
{
int y, x, key, display_key;
fd_set fdr;
......@@ -625,10 +750,18 @@ static int curses_terminal_get_esc_key(Tn5250Terminal * This,
return key;
}
/*
/****f* lib5250/tn5250_curses_terminal_use_underscores
* NAME
* tn5250_curses_terminal_use_underscores
* SYNOPSIS
* ret = tn5250_curses_terminal_use_underscores (This, v);
* INPUTS
* Tn5250Terminal * This -
* int v -
* DESCRIPTION
* Called by tn5250.c to determine whether we should use underscores or
* the terminal's underline attribute.
*/
* the terminal's underline attribute.
*****/
int tn5250_curses_terminal_use_underscores(Tn5250Terminal * This, int v)
{
int oldval = This->data->underscores;
......
......@@ -15,7 +15,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "tn5250-config.h"
#include <string.h>
#include <stdio.h>
......@@ -41,9 +40,17 @@
}
#endif
/*
* Allocate a new display buffer.
*/
/****f* lib5250/tn5250_dbuffer_new
* NAME
* tn5250_dbuffer_new
* SYNOPSIS
* ret = tn5250_dbuffer_new (width, height);
* INPUTS
* int width -
* int height -
* DESCRIPTION
* Allocates a new display buffer.
*****/
Tn5250DBuffer *tn5250_dbuffer_new(int width, int height)
{
int n;
......@@ -74,10 +81,17 @@ Tn5250DBuffer *tn5250_dbuffer_new(int width, int height)
return This;
}
/*
* Allocate a new display buffer and copy the contents of the old
/****f* lib5250/tn5250_dbuffer_copy
* NAME
* tn5250_dbuffer_copy
* SYNOPSIS
* ret = tn5250_dbuffer_copy (dsp);
* INPUTS
* Tn5250DBuffer * dsp -
* DESCRIPTION
* Allocates a new display buffer and copies the contents of the old
* one.
*/
*****/
Tn5250DBuffer *tn5250_dbuffer_copy(Tn5250DBuffer * dsp)
{
int n;
......@@ -113,9 +127,16 @@ Tn5250DBuffer *tn5250_dbuffer_copy(Tn5250DBuffer * dsp)
return This;
}
/*
/****f* lib5250/tn5250_dbuffer_destroy
* NAME
* tn5250_dbuffer_destroy
* SYNOPSIS
* tn5250_dbuffer_destroy (This);
* INPUTS
* Tn5250DBuffer * This -
* DESCRIPTION
* Free a display buffer and destroy all sub-structures.
*/
*****/
void tn5250_dbuffer_destroy(Tn5250DBuffer * This)
{
free(This->data);
......@@ -125,9 +146,18 @@ void tn5250_dbuffer_destroy(Tn5250DBuffer * This)
free(This);
}
/*
/****f* lib5250/tn5250_dbuffer_set_header_data
* NAME
* tn5250_dbuffer_set_header_data
* SYNOPSIS
* tn5250_dbuffer_set_header_data (This, data, len);
* INPUTS
* Tn5250DBuffer * This -
* unsigned char * data -
* int len -
* DESCRIPTION
* Set the format table header data.
*/
*****/
void tn5250_dbuffer_set_header_data(Tn5250DBuffer *This, unsigned char *data, int len)
{
if (This->header_data != NULL)
......@@ -141,10 +171,18 @@ void tn5250_dbuffer_set_header_data(Tn5250DBuffer *This, unsigned char *data, in
}
}
/*