From 770f6a8e3e5fa339feea7cf0a3d21786c803d3f0 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Fri, 3 Aug 2012 15:10:20 +0000 Subject: [PATCH] Mais ajustes para multi-sessão --- src/include/lib3270/session.h | 3 +++ src/lib3270/ctlr.c | 7 ++++--- src/lib3270/ft.c | 4 ++-- src/lib3270/ft_dft.c | 60 +++++++++++++++++++++++++++++++----------------------------- src/lib3270/ft_dftc.h | 6 +++--- src/lib3270/globals.h | 19 ++++++++++--------- src/lib3270/sf.c | 12 ++++++------ 7 files changed, 59 insertions(+), 52 deletions(-) diff --git a/src/include/lib3270/session.h b/src/include/lib3270/session.h index db29ccb..67d4adf 100644 --- a/src/include/lib3270/session.h +++ b/src/include/lib3270/session.h @@ -253,6 +253,9 @@ LIB3270_TA * ta_head; LIB3270_TA * ta_tail; + // ft_dft.c + int dft_buffersize; /**< Buffer size (LIMIN, LIMOUT) */ + // Widget info void * widget; diff --git a/src/lib3270/ctlr.c b/src/lib3270/ctlr.c index 2c162ce..0b0cf47 100644 --- a/src/lib3270/ctlr.c +++ b/src/lib3270/ctlr.c @@ -581,7 +581,7 @@ void ctlr_read_modified(H3270 *hSession, unsigned char aid_byte, Boolean all) #if defined(X3270_FT) /*[*/ if (aid_byte == AID_SF) { - dft_read_modified(); + dft_read_modified(hSession); return; } #endif /*]*/ @@ -765,8 +765,9 @@ void ctlr_read_buffer(H3270 *hSession, unsigned char aid_byte) unsigned char current_cs = 0x00; #if defined(X3270_FT) /*[*/ - if (aid_byte == AID_SF) { - dft_read_modified(); + if (aid_byte == AID_SF) + { + dft_read_modified(hSession); return; } #endif /*]*/ diff --git a/src/lib3270/ft.c b/src/lib3270/ft.c index bc8a218..72679ad 100644 --- a/src/lib3270/ft.c +++ b/src/lib3270/ft.c @@ -239,8 +239,8 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); } // Set options - dft_buffersize = dft; - set_dft_buffersize(); + session->dft_buffersize = dft; + set_dft_buffersize(session); // Initialize ft control structure. ft_last_cr = False; diff --git a/src/lib3270/ft_dft.c b/src/lib3270/ft_dft.c index f7555ec..8ce1bc5 100644 --- a/src/lib3270/ft_dft.c +++ b/src/lib3270/ft_dft.c @@ -77,7 +77,7 @@ struct data_buffer { }; /* Globals. */ -int dft_buffersize = 0; /* Buffer size (LIMIN, LIMOUT) */ +// int dft_buffersize = 0; /* Buffer size (LIMIN, LIMOUT) */ /* Statics. */ static Boolean message_flag = False; /* Open Request for msg received */ @@ -98,9 +98,11 @@ static void dft_open_request(unsigned short len, unsigned char *cp); static void dft_set_cur_req(void); static int filter_len(char *s, register int len); -/* Process a Transfer Data structured field from the host. */ -void -ft_dft_data(unsigned char *data, int length unused) +/** + * Process a Transfer Data structured field from the host. + * + */ +void ft_dft_data(H3270 *hSession, unsigned char *data, int length unused) { struct data_buffer *data_bufr = (struct data_buffer *)data; unsigned short data_length, data_type; @@ -353,9 +355,9 @@ dft_get_request(void) } /* Read a buffer's worth. */ - set_dft_buffersize(); - space3270out(&h3270,dft_buffersize); - numbytes = dft_buffersize - 27; /* always read 5 bytes less than we're allowed */ + set_dft_buffersize(&h3270); + space3270out(&h3270,h3270.dft_buffersize); + numbytes = h3270.dft_buffersize - 27; /* always read 5 bytes less than we're allowed */ bufptr = h3270.obuf + 17; while (!dft_eof && numbytes) { if (ascii_flag && cr_flag) { @@ -528,35 +530,35 @@ filter_len(char *s, register int len) return t - s; } -/* Processes a Read Modified command when there is upload data pending. */ -void -dft_read_modified(void) +/** + * Processes a Read Modified command when there is upload data pending. + */ +void dft_read_modified(H3270 *hSession) { if (dft_savebuf_len) { - trace_ds(&h3270,"> WriteStructuredField FileTransferData\n"); - h3270.obptr = h3270.obuf; - space3270out(&h3270,dft_savebuf_len); - memcpy(h3270.obptr, dft_savebuf, dft_savebuf_len); - h3270.obptr += dft_savebuf_len; - net_output(&h3270); + trace_ds(hSession,"> WriteStructuredField FileTransferData\n"); + hSession->obptr = hSession->obuf; + space3270out(hSession,dft_savebuf_len); + memcpy(hSession->obptr, dft_savebuf, dft_savebuf_len); + hSession->obptr += dft_savebuf_len; + net_output(hSession); } } -/* Update the buffersize for generating a Query Reply. */ -void -set_dft_buffersize(void) +/** + * Update the buffersize for generating a Query Reply. + */ +void set_dft_buffersize(H3270 *hSession) { - if (dft_buffersize == 0) - { -// dft_buffersize = appres.dft_buffer_size; -// if (dft_buffersize == 0) - dft_buffersize = DFT_BUF; - } - if (dft_buffersize > DFT_MAX_BUF) - dft_buffersize = DFT_MAX_BUF; - if (dft_buffersize < DFT_MIN_BUF) - dft_buffersize = DFT_MIN_BUF; + if (hSession->dft_buffersize == 0) + hSession->dft_buffersize = DFT_BUF; + + if (hSession->dft_buffersize > DFT_MAX_BUF) + hSession->dft_buffersize = DFT_MAX_BUF; + + if (hSession->dft_buffersize < DFT_MIN_BUF) + hSession->dft_buffersize = DFT_MIN_BUF; } diff --git a/src/lib3270/ft_dftc.h b/src/lib3270/ft_dftc.h index e92b510..b2856b8 100644 --- a/src/lib3270/ft_dftc.h +++ b/src/lib3270/ft_dftc.h @@ -14,6 +14,6 @@ * for more details. */ -LIB3270_INTERNAL void ft_dft_data(unsigned char *data, int length); -LIB3270_INTERNAL void dft_read_modified(void); -LIB3270_INTERNAL void set_dft_buffersize(void); +LIB3270_INTERNAL void ft_dft_data(H3270 *hSession, unsigned char *data, int length); +LIB3270_INTERNAL void dft_read_modified(H3270 *hSession); +LIB3270_INTERNAL void set_dft_buffersize(H3270 *hSession); diff --git a/src/lib3270/globals.h b/src/lib3270/globals.h index 69b1b3a..597461e 100644 --- a/src/lib3270/globals.h +++ b/src/lib3270/globals.h @@ -144,11 +144,12 @@ enum iaction { LIB3270_INTERNAL H3270 h3270; -#if defined(X3270_DISPLAY) /*[*/ +/* +#if defined(X3270_DISPLAY) LIB3270_INTERNAL Atom a_3270, a_registry, a_encoding; LIB3270_INTERNAL XtAppContext appcontext; -#endif /*]*/ - +#endif +*/ // Version strings LIB3270_INTERNAL const char * build; @@ -164,12 +165,12 @@ LIB3270_INTERNAL const char * build_rpq_revision; LIB3270_INTERNAL Boolean dbcs; #endif /*]*/ -#if defined(X3270_FT) /*[*/ - LIB3270_INTERNAL int dft_buffersize; -#endif /*]*/ +// #if defined(X3270_FT) /*[*/ +// LIB3270_INTERNAL int dft_buffersize; +// #endif /*]*/ // LIB3270_INTERNAL char *efontname; -LIB3270_INTERNAL Boolean ever_3270; +// LIB3270_INTERNAL Boolean ever_3270; // LIB3270_INTERNAL Boolean exiting; /* @@ -218,13 +219,13 @@ LIB3270_INTERNAL Boolean ever_3270; // LIB3270_INTERNAL char *qualified_host; // LIB3270_INTERNAL char *reconnect_host; // LIB3270_INTERNAL int screen_depth; -LIB3270_INTERNAL Boolean scroll_initted; +// LIB3270_INTERNAL Boolean scroll_initted; //#if defined(HAVE_LIBSSL) /*[*/ // LIB3270_INTERNAL Boolean secure_connection; //#endif /*]*/ -LIB3270_INTERNAL Boolean shifted; +// LIB3270_INTERNAL Boolean shifted; // LIB3270_INTERNAL Boolean ssl_host; LIB3270_INTERNAL Boolean *standard_font; // LIB3270_INTERNAL Boolean std_ds_host; diff --git a/src/lib3270/sf.c b/src/lib3270/sf.c index c9d2833..185842f 100644 --- a/src/lib3270/sf.c +++ b/src/lib3270/sf.c @@ -214,7 +214,7 @@ write_structured_field(unsigned char buf[], int buflen) #if defined(X3270_FT) /*[*/ case SF_TRANSFER_DATA: /* File transfer data */ trace_ds(&h3270,"FileTransferData"); - ft_dft_data(cp, (int)fieldlen); + ft_dft_data(&h3270,cp, (int)fieldlen); break; #endif /*]*/ default: @@ -951,14 +951,14 @@ do_qr_charsets(void) static void do_qr_ddm(void) { - set_dft_buffersize(); + set_dft_buffersize(&h3270); trace_ds(&h3270,"> QueryReply(DistributedDataManagement)\n"); space3270out(&h3270,8); - SET16(h3270.obptr,0); /* set reserved field to 0 */ - SET16(h3270.obptr, dft_buffersize); /* set inbound length limit INLIM */ - SET16(h3270.obptr, dft_buffersize); /* set outbound length limit OUTLIM */ - SET16(h3270.obptr, 0x0101); /* NSS=01, DDMSS=01 */ + SET16(h3270.obptr,0); /* set reserved field to 0 */ + SET16(h3270.obptr, h3270.dft_buffersize); /* set inbound length limit INLIM */ + SET16(h3270.obptr, h3270.dft_buffersize); /* set outbound length limit OUTLIM */ + SET16(h3270.obptr, 0x0101); /* NSS=01, DDMSS=01 */ } #endif /*]*/ -- libgit2 0.21.2