From 75274f99726dd080a47783e1ba4ea542f22a3caa Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Fri, 8 Feb 2019 02:43:39 -0200 Subject: [PATCH] Fixing windows warning Fixing multi-session issue --- src/include/seec.h | 2 +- src/lib3270/ctlr.c | 22 +++++++++++----------- src/lib3270/ft_cut.c | 19 ++++++++----------- src/lib3270/init.c | 5 +++++ src/lib3270/see.c | 46 +++++++++++----------------------------------- 5 files changed, 36 insertions(+), 58 deletions(-) diff --git a/src/include/seec.h b/src/include/seec.h index b45c123..e022b16 100644 --- a/src/include/seec.h +++ b/src/include/seec.h @@ -23,7 +23,7 @@ LIB3270_INTERNAL const char *see_aid(unsigned char code); LIB3270_INTERNAL const char *see_attr(unsigned char fa); LIB3270_INTERNAL const char *see_color(unsigned char setting); -LIB3270_INTERNAL const char *see_ebc(unsigned char ch); +LIB3270_INTERNAL const char *see_ebc(H3270 *hSession, unsigned char ch); LIB3270_INTERNAL const char *see_efa(unsigned char efa, unsigned char value); LIB3270_INTERNAL const char *see_efa_only(unsigned char efa); LIB3270_INTERNAL const char *see_qcode(unsigned char id); diff --git a/src/lib3270/ctlr.c b/src/lib3270/ctlr.c index 6dc4b16..2236ef0 100644 --- a/src/lib3270/ctlr.c +++ b/src/lib3270/ctlr.c @@ -945,7 +945,7 @@ void ctlr_read_modified(H3270 *hSession, unsigned char aid_byte, Boolean all) if (!any) trace_ds(hSession," '"); - trace_ds(hSession,"%s",see_ebc(hSession->ea_buf[baddr].cc)); + trace_ds(hSession,"%s",see_ebc(hSession, hSession->ea_buf[baddr].cc)); any = True; } INC_BA(baddr); @@ -994,7 +994,7 @@ void ctlr_read_modified(H3270 *hSession, unsigned char aid_byte, Boolean all) *hSession->obptr++ = hSession->ea_buf[baddr].cc; if (!any) trace_ds(hSession,"%s","'"); - trace_ds(hSession,"%s",see_ebc(hSession->ea_buf[baddr].cc)); + trace_ds(hSession,"%s",see_ebc(hSession, hSession->ea_buf[baddr].cc)); any = True; nbytes++; } @@ -1125,12 +1125,12 @@ void ctlr_read_buffer(H3270 *hSession, unsigned char aid_byte) if (any) trace_ds(hSession,"'"); - trace_ds(hSession," %s", see_ebc(hSession->ea_buf[baddr].cc)); + trace_ds(hSession," %s", see_ebc(hSession, hSession->ea_buf[baddr].cc)); any = False; } else { if (!any) trace_ds(hSession," '"); - trace_ds(hSession,"%s", see_ebc(hSession->ea_buf[baddr].cc)); + trace_ds(hSession,"%s", see_ebc(hSession, hSession->ea_buf[baddr].cc)); any = True; } } @@ -1484,7 +1484,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er if (add_c1) trace_ds(hSession,"'"); - trace_ds(hSession,"%s", see_ebc(add_c1)); + trace_ds(hSession,"%s", see_ebc(hSession, add_c1)); if (add_c1) trace_ds(hSession,"'"); @@ -1573,7 +1573,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er previous = ORDER; if (*cp) trace_ds(hSession,"'"); - trace_ds(hSession,"%s", see_ebc(*cp)); + trace_ds(hSession,"%s", see_ebc(hSession, *cp)); if (*cp) trace_ds(hSession,"'"); @@ -1788,7 +1788,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er case FCORDER_NL: case FCORDER_EM: case FCORDER_EO: - END_TEXT(see_ebc(*cp)); + END_TEXT(see_ebc(hSession, *cp)); previous = ORDER; d = ctlr_lookleft_state(buffer_addr, &why); if (hSession->default_cs == CS_DBCS || d != DBCS_NONE) { @@ -1805,7 +1805,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er break; case FCORDER_SO: /* Look left for errors. */ - END_TEXT(see_ebc(*cp)); + END_TEXT(see_ebc(hSession, *cp)); d = ctlr_lookleft_state(buffer_addr, &why); if (d == DBCS_RIGHT) { ABORT_WRITE("SO overwriting right half of DBCS character"); @@ -1829,7 +1829,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er break; case FCORDER_SI: /* Look left for errors. */ - END_TEXT(see_ebc(*cp)); + END_TEXT(see_ebc(hSession, *cp)); d = ctlr_lookleft_state(buffer_addr, &why); if (d == DBCS_RIGHT) { ABORT_WRITE("SI overwriting right half of DBCS character"); @@ -1889,7 +1889,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er case EBC_dup: case EBC_fm: /* DBCS control code */ - END_TEXT(see_ebc(add_c2)); + END_TEXT(see_ebc(hSession, add_c2)); add_dbcs = True; break; case ORDER_SF: @@ -1963,7 +1963,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er } else { #endif /*]*/ add_c1 = *cp; - trace_ds(hSession,"%s", see_ebc(*cp)); + trace_ds(hSession,"%s", see_ebc(hSession, *cp)); #if defined(X3270_DBCS) /*[*/ } #endif /*]*/ diff --git a/src/lib3270/ft_cut.c b/src/lib3270/ft_cut.c index 6a643c7..9faa809 100644 --- a/src/lib3270/ft_cut.c +++ b/src/lib3270/ft_cut.c @@ -119,7 +119,7 @@ static void cut_data(H3270 *hSession); static void cut_ack(H3270 *hSession); static void cut_abort(H3270 *hSession, unsigned short code, const char *fmt, ...) LIB3270_GNUC_FORMAT(3,4); -static unsigned from6(unsigned char c); +static unsigned from6(H3270 *hSession, unsigned char c); static int xlate_getc(H3270FT *ft); /** @@ -393,7 +393,7 @@ static void cut_data_request(H3270 *hSession) int i; unsigned char attr; - trace_ds(hSession,"< FT DATA_REQUEST %u\n", from6(seq)); + trace_ds(hSession,"< FT DATA_REQUEST %u\n", from6(hSession, seq)); if (lib3270_get_ft_state(hSession) == FT_ABORT_WAIT) { cut_abort(hSession,SC_ABORT_FILE,"%s", N_("Transfer cancelled by user") ); @@ -447,7 +447,7 @@ static void cut_data_request(H3270 *hSession) ctlr_add_fa(hSession,O_DR_SF, attr, 0); /* Send it up to the host. */ - trace_ds(hSession,"> FT DATA %u\n", from6(seq)); + trace_ds(hSession,"> FT DATA %u\n", from6(hSession, seq)); ft_update_length(ft); ft->expanded_length += count; @@ -463,14 +463,11 @@ static void cut_retransmit(H3270 *hSession) cut_abort(hSession,SC_ABORT_XMIT,"%s",_("Transmission error")); } -/* - * Convert an encoded integer. +/** + * @brief Convert an encoded integer. */ -static unsigned -from6(unsigned char c) +static unsigned from6(H3270 *hSession, unsigned char c) { - H3270 *hSession = lib3270_get_default_session_handle(); - char *p; c = hSession->charset.ebc2asc[c]; @@ -499,8 +496,8 @@ static void cut_data(H3270 *hSession) } /* Copy and convert the data. */ - raw_length = from6(hSession->ea_buf[O_DT_LEN].cc) << 6 | - from6(hSession->ea_buf[O_DT_LEN + 1].cc); + raw_length = from6(hSession, hSession->ea_buf[O_DT_LEN].cc) << 6 | + from6(hSession, hSession->ea_buf[O_DT_LEN + 1].cc); if ((int)raw_length > O_RESPONSE - O_DT_DATA) { diff --git a/src/lib3270/init.c b/src/lib3270/init.c index 24f0fea..6b1b66d 100644 --- a/src/lib3270/init.c +++ b/src/lib3270/init.c @@ -32,6 +32,11 @@ * @brief Init/Deinit lib3270 internals. */ +#ifdef _WIN32 + #include + #include +#endif // _WIN32 + #include #ifdef HAVE_LIBCURL diff --git a/src/lib3270/see.c b/src/lib3270/see.c index bba981a..4154009 100644 --- a/src/lib3270/see.c +++ b/src/lib3270/see.c @@ -61,10 +61,8 @@ unknown(unsigned char value) return buf; } -const char * -see_ebc(unsigned char ch) +const char *see_ebc(H3270 *hSession, unsigned char ch) { - H3270 *hSession = lib3270_get_default_session_handle(); static char buf[8]; switch (ch) { @@ -97,23 +95,10 @@ see_ebc(unsigned char ch) else (void) sprintf(buf, "\\%o", ch); -/* - if (ebc2asc[ch]) - (void) sprintf(buf, -#if !defined(PR3287) - "%s", utf8_expand(ebc2asc[ch]) -#else - "%c", ebc2asc[ch] -#endif - ); - else - (void) sprintf(buf, "\\%o", ch); -*/ return buf; } -const char * -see_aid(unsigned char code) +const char * see_aid(unsigned char code) { switch (code) { case AID_NO: @@ -191,8 +176,7 @@ see_aid(unsigned char code) } } -const char * -see_attr(unsigned char fa) +const char * see_attr(unsigned char fa) { static char buf[256]; const char *paren = "("; @@ -245,8 +229,7 @@ see_attr(unsigned char fa) return buf; } -static const char * -see_highlight(unsigned char setting) +static const char * see_highlight(unsigned char setting) { switch (setting) { case XAH_DEFAULT: @@ -266,8 +249,7 @@ see_highlight(unsigned char setting) } } -const char * -see_color(unsigned char setting) +const char * see_color(unsigned char setting) { static const char *color_name[] = { "neutralBlack", @@ -296,8 +278,7 @@ see_color(unsigned char setting) return color_name[setting - 0xf0]; } -static const char * -see_transparency(unsigned char setting) +static const char * see_transparency(unsigned char setting) { switch (setting) { case XAT_DEFAULT: @@ -313,8 +294,7 @@ see_transparency(unsigned char setting) } } -static const char * -see_validation(unsigned char setting) +static const char * see_validation(unsigned char setting) { static char buf[64]; const char *paren = "("; @@ -342,8 +322,7 @@ see_validation(unsigned char setting) return buf; } -static const char * -see_outline(unsigned char setting) +static const char * see_outline(unsigned char setting) { static char buf[64]; const char *paren = "("; @@ -376,8 +355,7 @@ see_outline(unsigned char setting) return buf; } -static const char * -see_input_control(unsigned char setting) +static const char * see_input_control(unsigned char setting) { switch (setting) { case XAI_DISABLED: @@ -389,8 +367,7 @@ see_input_control(unsigned char setting) } } -const char * -see_efa(unsigned char efa, unsigned char value) +const char * see_efa(unsigned char efa, unsigned char value) { static char buf[64]; @@ -434,8 +411,7 @@ see_efa(unsigned char efa, unsigned char value) return buf; } -const char * -see_efa_only(unsigned char efa) +const char * see_efa_only(unsigned char efa) { switch (efa) { case XA_ALL: -- libgit2 0.21.2