From c94e0cc37d042472794f27461ae73062ba638839 Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Thu, 5 May 2016 15:57:17 -0300 Subject: [PATCH] Download de arquivos texto precisa de tratamento diferente em windows (CR+LF & 0x1a no final). --- ft.c | 19 +++++++++++-------- ft_cut.c | 7 ++++--- ft_dft.c | 9 ++++++--- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/ft.c b/ft.c index c7dab90..38daa6d 100644 --- a/ft.c +++ b/ft.c @@ -298,6 +298,7 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); 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->unix_text = (flags & LIB3270_FT_OPTION_UNIX) ? 1 : 0; ftHandle->ft_is_cut = 0; ftHandle->flags = flags; ftHandle->local_file = ft_local_file; @@ -366,11 +367,12 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); // Receiving file lib3270_write_dstrace( ft->host, - "\nReceiving file %s (%s %s %s)\n", + "\nReceiving file %s (%s %s %s %s)\n", ft->local, - ft->ascii_flag ? "ASCII" : "BINARY", - ft->cr_flag ? "CRLF" : "NOCRLF", - ft->remap_flag ? "REMAP" : "NOREMAP" + ft->ascii_flag ? "ASCII" : "BINARY", + ft->cr_flag ? "CRLF" : "NOCRLF", + ft->remap_flag ? "REMAP" : "NOREMAP", + ft->unix_text ? "LF Only" : "CR/LF" ); } else @@ -386,12 +388,13 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); lib3270_write_dstrace( ft->host, - "\nSending file %s (%ld bytes %s %s %s)\n", + "\nSending file %s (%ld bytes %s %s %s %s)\n", ft->local, ft->length, - ft->ascii_flag ? "ASCII" : "BINARY", - ft->cr_flag ? "CRLF" : "NOCRLF", - ft->remap_flag ? "REMAP" : "NOREMAP" + ft->ascii_flag ? "ASCII" : "BINARY", + ft->cr_flag ? "CRLF" : "NOCRLF", + ft->remap_flag ? "REMAP" : "NOREMAP", + ft->unix_text ? "LF only" : "CR/LF" ); rewind(ft->local_file); diff --git a/ft_cut.c b/ft_cut.c index 9cbc3d0..6382f69 100644 --- a/ft_cut.c +++ b/ft_cut.c @@ -192,11 +192,12 @@ static int upload_convert(H3270 *hSession, unsigned char *buf, int len) /* Map it. */ c = conv[ft->quadrant].xlate[ix]; - if (ft->ascii_flag && ft->cr_flag && (c == '\r' || c == 0x1a)) +// if (ft->ascii_flag && ft->cr_flag && (c == '\r' || c == 0x1a)) + if (ft->unix_text && (c == '\r' || c == 0x1a)) continue; - - if (ft->ascii_flag && ft->remap_flag) + else if (ft->ascii_flag && ft->remap_flag) c = ft->charset.ebc2asc[c]; + *ob++ = c; } diff --git a/ft_dft.c b/ft_dft.c index b846544..fded513 100644 --- a/ft_dft.c +++ b/ft_dft.c @@ -294,12 +294,15 @@ static void dft_data_insert(H3270 *hSession, struct data_buffer *data_bufr) s++; } } - if (ft->ascii_flag && ft->cr_flag) + +// if (ft->ascii_flag && ft->cr_flag) + if (ft->unix_text) { + /* Delete CRs and ^Zs. */ + char *s = (char *)data_bufr->data; unsigned len = my_length; - /* Delete CRs and ^Zs. */ while (len) { unsigned l = filter_len(s, len); @@ -375,7 +378,7 @@ static void dft_get_request(H3270 *hSession) while (!ft->dft_eof && numbytes) { - if (ft->ascii_flag && ft->cr_flag) + if (ft->unix_text) { // ASCII text file -- libgit2 0.21.2