From 5d80a5c34473c1b2705d40b124a3dc4469c0740f Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Thu, 28 Nov 2013 15:42:31 +0000 Subject: [PATCH] Corrigindo opções da transferência de arquivos --- charset.c | 20 ++++++++++---------- ft.c | 39 +++++++++++++++++++++++++++++---------- ft_cut.c | 4 ++-- ft_dft.c | 12 +++++++----- 4 files changed, 48 insertions(+), 27 deletions(-) diff --git a/charset.c b/charset.c index 57ea64a..d455e51 100644 --- a/charset.c +++ b/charset.c @@ -132,6 +132,7 @@ static const unsigned short asc2ebc0[256] = /*f8*/ 0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf }; +/* static const unsigned short ft2asc[256] = { 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f, @@ -171,6 +172,7 @@ const unsigned short asc2ft[256] = 0xa3,0xa4,0xa1,0xa5,0xa2,0xa6,0xcd,0xa7,0xac,0xa9,0xaa,0xab,0xb0,0xad,0xae,0xaf, 0xc6,0xa8,0xeb,0xec,0xe9,0xed,0xea,0x9f,0xba,0xf1,0xf2,0xef,0xf0,0xc7,0xc8,0xf3 }; +*/ static const unsigned short asc2uc[UT_SIZE] = { @@ -271,10 +273,12 @@ LIB3270_EXPORT int lib3270_set_host_charset(H3270 *hSession, const char *name) hSession->charset.asc2uc[f] = f; copy_charset(asc2uc,hSession->charset.asc2uc); +/* #if defined(X3270_FT) memcpy(hSession->charset.ft2asc, ft2asc, sizeof(hSession->charset.ft2asc)); memcpy(hSession->charset.asc2ft, asc2ft, sizeof(hSession->charset.asc2ft)); #endif +*/ if(!(name && strcasecmp(name,hSession->charset.host))) return 0; @@ -451,9 +455,9 @@ LIB3270_EXPORT void lib3270_remap(H3270 *hSession, unsigned short ebc, unsigned if (iso <= 0xff) { -#if defined(X3270_FT) - unsigned char aa; -#endif +//#if defined(X3270_FT) +// unsigned char aa; +//#endif if (scope == BOTH || scope == CS_ONLY) { @@ -484,6 +488,8 @@ LIB3270_EXPORT void lib3270_remap(H3270 *hSession, unsigned short ebc, unsigned hSession->charset.asc2ebc[iso] = ebc; } } + +/* #if defined(X3270_FT) if (iso <= 0xff && ebc > 0x40) { @@ -522,14 +528,8 @@ LIB3270_EXPORT void lib3270_remap(H3270 *hSession, unsigned short ebc, unsigned } } #endif - } -/* - else - { - // Auto-keymap. - add_xk(iso, (KeySym)hSession->charset.ebc2asc[ebc]); - } */ + } } diff --git a/ft.c b/ft.c index 09c8cac..214fd48 100644 --- a/ft.c +++ b/ft.c @@ -210,9 +210,10 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); ftHandle->host = session; ftHandle->ft_last_cr = 0; - ftHandle->remap_flag = 1; // Remap ASCII<->EBCDIC - ftHandle->cr_flag = 1; - ftHandle->ascii_flag = 1; + + ftHandle->ascii_flag = (flags & LIB3270_FT_OPTION_ASCII) ? 1 : 0; + ftHandle->cr_flag = (flags & LIB3270_FT_OPTION_CRLF) ? 1 : 0; + ftHandle->remap_flag = (flags & LIB3270_FT_OPTION_REMAP) ? 1 : 0; ftHandle->ft_is_cut = 0; ftHandle->flags = flags; ftHandle->local_file = ft_local_file; @@ -230,6 +231,7 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); ftHandle->dft = dft; ftHandle->quadrant = -1; + memcpy(&ftHandle->charset,&session->charset,sizeof(struct lib3270_charset)); ftHandle->local = (char *) (ftHandle+1); strcpy((char *) ftHandle->local,local); @@ -239,6 +241,8 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); session->ft = ftHandle; + + return ftHandle; } @@ -260,16 +264,23 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); if(!ft) return EINVAL; - recfm = (ft->flags & FT_RECORD_FORMAT_MASK) >> 8; - units = (ft->flags & FT_ALLOCATION_UNITS_MASK) >> 12; - ft->ascii_flag = ((ft->flags & LIB3270_FT_OPTION_ASCII) == 0) ? 1 : 0; - ft->cr_flag = ((ft->flags & LIB3270_FT_OPTION_CRLF) == 0) ? 1 : 0; - ft->remap_flag = ((ft->flags & LIB3270_FT_OPTION_ASCII) == 0) ? 1 : 0; + recfm = (ft->flags & FT_RECORD_FORMAT_MASK) >> 8; + units = (ft->flags & FT_ALLOCATION_UNITS_MASK) >> 12; + ft->ascii_flag = (ft->flags & LIB3270_FT_OPTION_ASCII) ? 1 : 0; + ft->cr_flag = (ft->flags & LIB3270_FT_OPTION_CRLF) ? 1 : 0; + ft->remap_flag = (ft->flags & LIB3270_FT_OPTION_REMAP) ? 1 : 0; if(ft->flags & LIB3270_FT_OPTION_RECEIVE) { // Receiving file - lib3270_write_log(ft->host,"ft","Receiving file %s",ft->local); + lib3270_write_log( ft->host, + "ft", + "Receiving file %s %s %s %s", + ft->local, + ft->ascii_flag ? "ASCII" : "BINARY", + ft->cr_flag ? "CRLF" : "NOCRLF", + ft->remap_flag ? "REMAP" : "NOREMAP" + ); } else { @@ -283,7 +294,15 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); ft->length = ftell(ft->local_file); - lib3270_write_log(ft->host,"ft","Sending file %s (%ld bytes)",ft->local,ft->length); + lib3270_write_log( ft->host, + "ft", + "Sending file %s (%ld bytes) %s %s %s", + ft->local, + ft->length, + ft->ascii_flag ? "ASCII" : "BINARY", + ft->cr_flag ? "CRLF" : "NOCRLF", + ft->remap_flag ? "REMAP" : "NOREMAP" + ); rewind(ft->local_file); } diff --git a/ft_cut.c b/ft_cut.c index d03cf9d..0450373 100644 --- a/ft_cut.c +++ b/ft_cut.c @@ -194,7 +194,7 @@ static int upload_convert(H3270 *hSession, unsigned char *buf, int len) if (ft->ascii_flag && ft->cr_flag && (c == '\r' || c == 0x1a)) continue; if (ft->ascii_flag && ft->remap_flag) - c = hSession->charset.ft2asc[c]; + c = ft->charset.ebc2asc[c]; *ob++ = c; } @@ -231,7 +231,7 @@ static int download_convert(H3270FT *ft, unsigned const char *buf, unsigned len, /* Translate. */ if (ft->ascii_flag && ft->remap_flag) - c = hSession->charset.asc2ft[c]; + c = ft->charset.asc2ebc[c]; /* Quadrant already defined. */ if (ft->quadrant >= 0) { diff --git a/ft_dft.c b/ft_dft.c index 5d02a05..68f73b7 100644 --- a/ft_dft.c +++ b/ft_dft.c @@ -304,7 +304,7 @@ static void dft_data_insert(H3270 *hSession, struct data_buffer *data_bufr) while (len--) { - *s = hSession->charset.ft2asc[*s]; + *s = ft->charset.ebc2asc[*s]; s++; } } @@ -413,7 +413,7 @@ static void dft_get_request(H3270 *hSession) total_read++; } ft->ft_last_cr = (c == '\r') ? 1 : 0; - *bufptr++ = ft->remap_flag? hSession->charset.asc2ft[c]: c; + *bufptr++ = ft->remap_flag ? ft->charset.asc2ebc[c]: c; numbytes--; total_read++; } else { @@ -422,12 +422,14 @@ static void dft_get_request(H3270 *hSession) if (numread <= 0) { break; } - if (ft->ascii_flag && ft->remap_flag) { + if (ft->ascii_flag && ft->remap_flag) + { unsigned char *s = bufptr; int i = numread; - while (i) { - *s = hSession->charset.asc2ft[*s]; + while (i) + { + *s = ft->charset.asc2ebc[*s]; s++; i--; } -- libgit2 0.21.2