From 499a94cac2c5cf2e3698dca5538f880bfd318a8a Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Mon, 6 Aug 2012 15:00:32 +0000 Subject: [PATCH] Ajustes para multi-sessão --- ft.c | 2 +- ft_cut.c | 25 ++++++++++++------------- globals.h | 12 ------------ kybd.c | 16 ++++++++-------- rpq.c | 4 ++-- screen.c | 10 +++++----- telnet.c | 88 ++-------------------------------------------------------------------------------------- trace_ds.c | 15 --------------- trace_dsc.h | 7 +++---- 9 files changed, 33 insertions(+), 146 deletions(-) diff --git a/ft.c b/ft.c index ef80edf..adefec6 100644 --- a/ft.c +++ b/ft.c @@ -379,7 +379,7 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); return errno = EINVAL; } - trace_event("Sending FT request:\n%s\n",buffer); + lib3270_trace_event(hSession,"Sending FT request:\n%s\n",buffer); lib3270_emulate_input(ft->host, buffer, strlen(buffer), False); diff --git a/ft_cut.c b/ft_cut.c index 947513c..1df6d51 100644 --- a/ft_cut.c +++ b/ft_cut.c @@ -18,7 +18,7 @@ * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin * St, Fifth Floor, Boston, MA 02110-1301 USA * - * Este programa está nomeado como ft_cut.c e possui 591 linhas de código. + * Este programa está nomeado como ft_cut.c e possui - linhas de código. * * Contatos: * @@ -26,12 +26,12 @@ * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) * licinio@bb.com.br (Licínio Luis Branco) * kraucer@bb.com.br (Kraucer Fernandes Mazuco) - * macmiranda@bb.com.br (Marco Aurélio Caldas Miranda) * */ -/* - * ft_cut.c +/** + * @file ft_cut.c + * * File transfer, data movement logic, CUT version */ @@ -54,7 +54,7 @@ #include "trace_dsc.h" #include "utilc.h" -static Boolean cut_xfer_in_progress = False; +// static Boolean cut_xfer_in_progress = 0; /* Data stream conversion tables. */ @@ -63,10 +63,10 @@ static Boolean cut_xfer_in_progress = False; #define OTHER_2 2 /* "OTHER 2" quadrant (includes NULL) */ #define XLATE_NULL 0xc1 /* translation of NULL */ -static char alphas[NE + 1] = -" ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%&_()<+,-./:>?"; +static const char alphas[NE + 1] = " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%&_()<+,-./:>?"; -static struct { +static const struct +{ unsigned char selector; unsigned char xlate[NE]; } conv[NQ] = { @@ -107,8 +107,7 @@ static struct { 0xbe,0xbf,0x9a,0x9b, 0x00 } } }; -static char table6[] = - "abcdefghijklmnopqrstuvwxyz&-.,:+ABCDEFGHIJKLMNOPQRSTUVWXYZ012345"; +static const char table6[] = "abcdefghijklmnopqrstuvwxyz&-.,:+ABCDEFGHIJKLMNOPQRSTUVWXYZ012345"; static int quadrant = -1; static unsigned long expanded_length; @@ -317,7 +316,7 @@ static void cut_control_code(H3270 *hSession) { case SC_HOST_ACK: trace_ds(hSession,"HOST_ACK\n"); - cut_xfer_in_progress = True; + hSession->cut_xfer_in_progress = 1; expanded_length = 0; quadrant = -1; xlate_buffered = 0; @@ -328,14 +327,14 @@ static void cut_control_code(H3270 *hSession) case SC_XFER_COMPLETE: trace_ds(hSession,"XFER_COMPLETE\n"); cut_ack(hSession); - cut_xfer_in_progress = False; + hSession->cut_xfer_in_progress = 0; ft_complete(NULL,N_( "Complete" ) ); break; case SC_ABORT_FILE: case SC_ABORT_XMIT: trace_ds(hSession,"ABORT\n"); - cut_xfer_in_progress = False; + hSession->cut_xfer_in_progress = 0; cut_ack(hSession); if (lib3270_get_ft_state(hSession) == FT_ABORT_SENT && saved_errmsg != CN) diff --git a/globals.h b/globals.h index 72f457c..3764423 100644 --- a/globals.h +++ b/globals.h @@ -252,18 +252,6 @@ LIB3270_INTERNAL const char * build_rpq_revision; /* Connection state */ // LIB3270_INTERNAL enum ft_state ft_state; -/* -LIB3270_INTERNAL enum cstate cstate; -#define PCONNECTED ((int)h3270.cstate >= (int)RESOLVING) -#define HALF_CONNECTED (h3270.cstate == RESOLVING || h3270.cstate == PENDING) -#define CONNECTED ((int)h3270.cstate >= (int)CONNECTED_INITIAL) -#define IN_NEITHER (h3270.cstate == CONNECTED_INITIAL) -#define IN_ANSI (h3270.cstate == CONNECTED_ANSI || h3270.cstate == CONNECTED_NVT) -#define IN_3270 (h3270.cstate == CONNECTED_3270 || h3270.cstate == CONNECTED_TN3270E || h3270.cstate == CONNECTED_SSCP) -#define IN_SSCP (h3270.cstate == CONNECTED_SSCP) -#define IN_TN3270E (h3270.cstate == CONNECTED_TN3270E) -#define IN_E (h3270.cstate >= CONNECTED_INITIAL_E) -*/ /* keyboard modifer bitmap */ #define ShiftKeyDown 0x01 diff --git a/kybd.c b/kybd.c index 148823d..571d097 100644 --- a/kybd.c +++ b/kybd.c @@ -257,7 +257,7 @@ static int enq_chk(H3270 *hSession) } session->ta_tail = ta; - trace_event(" Key-aid queued (kybdlock 0x%x)\n", session->kybdlock); + lib3270_trace_event(session," Key-aid queued (kybdlock 0x%x)\n", session->kybdlock); } /* @@ -300,7 +300,7 @@ static void enq_ta(H3270 *hSession, void (*fn)(H3270 *, const char *, const char } hSession->ta_tail = ta; - trace_event(" action queued (kybdlock 0x%x)\n", hSession->kybdlock); + lib3270_trace_event(hSession," action queued (kybdlock 0x%x)\n", hSession->kybdlock); } /* @@ -374,7 +374,7 @@ static void kybdlock_set(H3270 *hSession, unsigned int bits) { /* #if defined(KYBDLOCK_TRACE) - trace_event(" %s: kybdlock |= 0x%04x, 0x%04x -> 0x%04x\n", + lib3270_trace_event(hSession," %s: kybdlock |= 0x%04x, 0x%04x -> 0x%04x\n", cause, bits, kybdlock, n); #endif */ @@ -399,7 +399,7 @@ void lib3270_kybdlock_clear(H3270 *hSession, LIB3270_KL_STATE bits) if (n != hSession->kybdlock) { #if defined(KYBDLOCK_TRACE) - trace_event(" %s: kybdlock &= ~0x%04x, 0x%04x -> 0x%04x\n", __FUNCTION__, bits, kybdlock, n); + lib3270_trace_event(hSession," %s: kybdlock &= ~0x%04x, 0x%04x -> 0x%04x\n", __FUNCTION__, bits, kybdlock, n); #endif if ((hSession->kybdlock ^ n) & KL_DEFERRED_UNLOCK) { @@ -734,7 +734,7 @@ static void key_Character_wrapper(H3270 *hSession, const char *param1, const cha code &= ~PASTE_WFLAG; } -// trace_event(" %s -> Key(%s\"%s\")\n",ia_name[(int) ia_cause],with_ge ? "GE " : "",ctl_see((int) ebc2asc[code])); +// lib3270_trace_event(hSession," %s -> Key(%s\"%s\")\n",ia_name[(int) ia_cause],with_ge ? "GE " : "",ctl_see((int) ebc2asc[code])); (void) key_Character(hSession, code, with_ge, pasting, NULL); } @@ -1963,7 +1963,7 @@ LIB3270_ACTION( clear ) return 0; } #endif /*]*/ - h3270.buffer_addr = 0; + hSession->buffer_addr = 0; ctlr_clear(hSession,True); cursor_move(hSession,0); if (CONNECTED) @@ -2517,7 +2517,7 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *hSession, char *s, int len, int */ if (hSession->kybdlock) { - trace_event(" keyboard locked, string dropped\n"); + lib3270_trace_event(hSession," keyboard locked, string dropped\n"); return 0; } @@ -2621,7 +2621,7 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *hSession, char *s, int len, int (void) key_WCharacter(ebc, &skipped); break; } else { - trace_event("Cannot convert U+%04x to " + lib3270_trace_event(hSession,"Cannot convert U+%04x to " "EBCDIC\n", c & 0xffff); break; } diff --git a/rpq.c b/rpq.c index 29db8f2..b0800a7 100644 --- a/rpq.c +++ b/rpq.c @@ -228,14 +228,14 @@ void do_qr_rpqnames(H3270 *hSession) * adjust space remaining. * obptr now points at "next available byte". */ - x = h3270.obptr-p_term; + x = hSession->obptr-p_term; if (x > TERM_PREFIX_SIZE) { *p_term = x; remaining -= x; /* This includes length and id fields, correction below */ } else { /* We didn't add an item after all, reset pointer. */ - h3270.obptr = p_term; + hSession->obptr = p_term; } /* * When we calculated the length of the term, a few lines diff --git a/screen.c b/screen.c index 76be4fe..70677d8 100644 --- a/screen.c +++ b/screen.c @@ -83,7 +83,7 @@ static int (*popup_handler)(H3270 *, void *, LIB3270_NOTIFY, const char *, const static void status_connect(H3270 *session, int ignored, void *dunno); static void status_3270_mode(H3270 *session, int ignored, void *dunno); // static void status_printer(H3270 *session, int on, void *dunno); -static unsigned short color_from_fa(unsigned char fa); +static unsigned short color_from_fa(H3270 *hSession, unsigned char fa); /*--[ Implement ]------------------------------------------------------------------------------------*/ @@ -146,9 +146,9 @@ int screen_init(H3270 *session) } /* Map a field attribute to its default colors. */ -static unsigned short color_from_fa(unsigned char fa) +static unsigned short color_from_fa(H3270 *hSession, unsigned char fa) { - if (h3270.m3279) + if (hSession->m3279) return get_color_pair(DEFCOLOR_MAP(fa),0) | COLOR_ATTR_FIELD; // Green on black @@ -172,7 +172,7 @@ static unsigned short calc_attrs(H3270 *session, int baddr, int fa_addr, int fa) !session->ea_buf[baddr].bg && !session->ea_buf[fa_addr].bg)) { - a = color_from_fa(fa); + a = color_from_fa(session,fa); } else { @@ -299,7 +299,7 @@ void screen_update(H3270 *session, int bstart, int bend) int last = -1; fa = get_field_attribute(session,bstart); - a = color_from_fa(fa); + a = color_from_fa(session,fa); fa_addr = find_field_attribute(session,bstart); // may be -1, that's okay #ifdef WIN32 diff --git a/telnet.c b/telnet.c index aaffd20..9515564 100644 --- a/telnet.c +++ b/telnet.c @@ -26,7 +26,6 @@ * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) * licinio@bb.com.br (Licínio Luis Branco) * kraucer@bb.com.br (Kraucer Fernandes Mazuco) - * macmiranda@bb.com.br (Marco Aurélio Caldas Miranda) * */ @@ -314,17 +313,8 @@ static const char *trsp_flag[2] = { "POSITIVE-RESPONSE", "NEGATIVE-RESPONSE" }; #endif /*]*/ #endif /*]*/ -// #if defined(C3270) && defined(C3270_80_132) /*[*/ -// #define XMIT_ROWS ((appres.altscreen != CN)? 24: maxROWS) -// #define XMIT_COLS ((appres.altscreen != CN)? 80: maxCOLS) -// #else /*][*/ -#define XMIT_ROWS h3270.maxROWS -#define XMIT_COLS h3270.maxCOLS -// #endif /*]*/ - -// #if defined(HAVE_LIBSSL) -// static SSL *ssl_con; -// #endif +#define XMIT_ROWS hSession->maxROWS +#define XMIT_COLS hSession->maxCOLS #if defined(HAVE_LIBSSL) /*[*/ // static Boolean need_tls_follows = False; @@ -338,10 +328,6 @@ static void ssl_info_callback(INFO_CONST SSL *s, int where, int ret); static void continue_tls(H3270 *hSession, unsigned char *sbbuf, int len); #endif /*]*/ -// #if !defined(_WIN32) /*[*/ -// static void output_possible(H3270 *session); -// #endif /*]*/ - #if defined(_WIN32) /*[*/ #define socket_errno() WSAGetLastError() #define SE_EWOULDBLOCK WSAEWOULDBLOCK @@ -1838,25 +1824,6 @@ tn3270e_function_names(const unsigned char *buf, int len) } #endif /*]*/ -/* Expand the current TN3270E function codes into text. */ /* -const char * -tn3270e_current_opts(void) -{ - int i; - static char text_buf[1024]; - char *s = text_buf; - - if (!h3270.e_funcs || !IN_E) - return CN; - for (i = 0; i < 32; i++) { - if (h3270.e_funcs & E_OPT(i)) - s += sprintf(s, "%s%s", (s == text_buf) ? "" : " ", - fnn(i)); - } - return text_buf; -} -*/ - /* Transmit a TN3270E FUNCTIONS REQUEST or FUNCTIONS IS message. */ static void tn3270e_subneg_send(H3270 *hSession, unsigned char op, unsigned long funcs) { @@ -3316,61 +3283,10 @@ int net_getsockname(const H3270 *session, void *buf, int *len) return getsockname(session->sock, buf, (socklen_t *)(void *)len); } -/* Return a text version of the current proxy type, or NULL. */ /* -char * -net_proxy_type(void) -{ - if(h3270.proxy_type > 0) - return proxy_type_name(h3270.proxy_type); - else - return NULL; -} -*/ - -/* Return the current proxy host, or NULL. */ /* -char * -net_proxy_host(void) -{ - if(h3270.proxy_type > 0) - return h3270.proxy_host; - else - return NULL; -} -*/ - -/* Return the current proxy port, or NULL. */ /* -char * -net_proxy_port(void) -{ - if (h3270.proxy_type > 0) - return h3270.proxy_portname; - else - return NULL; -} -*/ - LIB3270_EXPORT LIB3270_SSL_STATE lib3270_get_secure(H3270 *session) { CHECK_SESSION_HANDLE(session); return session->secure; } -/* -LIB3270_EXPORT int lib3270_get_ssl_state(H3270 *h) -{ - CHECK_SESSION_HANDLE(h); -#if defined(HAVE_LIBSSL) - return (h->secure_connection != 0); -#else - return 0; -#endif -} -*/ - -/* -int Get3270Socket(void) -{ - return h3270.sock; -} -*/ diff --git a/trace_ds.c b/trace_ds.c index 1936eec..8b40239 100644 --- a/trace_ds.c +++ b/trace_ds.c @@ -214,21 +214,6 @@ void trace_ds_nb(H3270 *hSession, const char *fmt, ...) lib3270_free(text); } -/* Conditional event trace. */ /* -void trace_event(const char *fmt, ...) -{ - va_list args; - - if (!lib3270_get_toggle(&h3270,EVENT_TRACE)) - return; - - // print out message - va_start(args, fmt); - vwtrace(&h3270,fmt, args); - va_end(args); -} -*/ - /* Conditional data stream trace, without line splitting. */ void trace_dsn(H3270 *hSession, const char *fmt, ...) { diff --git a/trace_dsc.h b/trace_dsc.h index 6456526..6b8844f 100644 --- a/trace_dsc.h +++ b/trace_dsc.h @@ -47,25 +47,24 @@ void trace_ds(H3270 *hSession, const char *fmt, ...) printflike(2, 3); void trace_ds_nb(H3270 *hSession, const char *fmt, ...) printflike(2, 3); void trace_dsn(H3270 *hSession, const char *fmt, ...) printflike(2, 3); -// void trace_event(const char *fmt, ...) printflike(1, 2); void trace_screen(H3270 *session); // void trace_rollover_check(void); - #define trace_event(...) lib3270_trace_event(&h3270,__VA_ARGS__) +// #define trace_event(...) lib3270_trace_event(&h3270,__VA_ARGS__) #elif defined(__GNUC__) #define trace_ds(session, format, args...) #define trace_dsn(session, format, args...) #define trace_ds_nb(session, format, args...) - #define trace_event(session, format, args...) +// #define trace_event(session, format, args...) #else #define trace_ds 0 && #define trace_ds_nb 0 && #define trace_dsn 0 && - #define trace_event 0 && +// #define trace_event 0 && #define rcba 0 && #endif -- libgit2 0.21.2