Commit c94e0cc37d042472794f27461ae73062ba638839
1 parent
626582c7
Exists in
master
and in
3 other branches
Download de arquivos texto precisa de tratamento diferente em windows (CR+LF & 0x1a no final).
Showing
3 changed files
with
21 additions
and
14 deletions
Show diff stats
@@ -298,6 +298,7 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); | @@ -298,6 +298,7 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); | ||
298 | ftHandle->ascii_flag = (flags & LIB3270_FT_OPTION_ASCII) ? 1 : 0; | 298 | ftHandle->ascii_flag = (flags & LIB3270_FT_OPTION_ASCII) ? 1 : 0; |
299 | ftHandle->cr_flag = (flags & LIB3270_FT_OPTION_CRLF) ? 1 : 0; | 299 | ftHandle->cr_flag = (flags & LIB3270_FT_OPTION_CRLF) ? 1 : 0; |
300 | ftHandle->remap_flag = (flags & LIB3270_FT_OPTION_REMAP) ? 1 : 0; | 300 | ftHandle->remap_flag = (flags & LIB3270_FT_OPTION_REMAP) ? 1 : 0; |
301 | + ftHandle->unix_text = (flags & LIB3270_FT_OPTION_UNIX) ? 1 : 0; | ||
301 | ftHandle->ft_is_cut = 0; | 302 | ftHandle->ft_is_cut = 0; |
302 | ftHandle->flags = flags; | 303 | ftHandle->flags = flags; |
303 | ftHandle->local_file = ft_local_file; | 304 | ftHandle->local_file = ft_local_file; |
@@ -366,11 +367,12 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); | @@ -366,11 +367,12 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); | ||
366 | // Receiving file | 367 | // Receiving file |
367 | lib3270_write_dstrace( | 368 | lib3270_write_dstrace( |
368 | ft->host, | 369 | ft->host, |
369 | - "\nReceiving file %s (%s %s %s)\n", | 370 | + "\nReceiving file %s (%s %s %s %s)\n", |
370 | ft->local, | 371 | ft->local, |
371 | - ft->ascii_flag ? "ASCII" : "BINARY", | ||
372 | - ft->cr_flag ? "CRLF" : "NOCRLF", | ||
373 | - ft->remap_flag ? "REMAP" : "NOREMAP" | 372 | + ft->ascii_flag ? "ASCII" : "BINARY", |
373 | + ft->cr_flag ? "CRLF" : "NOCRLF", | ||
374 | + ft->remap_flag ? "REMAP" : "NOREMAP", | ||
375 | + ft->unix_text ? "LF Only" : "CR/LF" | ||
374 | ); | 376 | ); |
375 | } | 377 | } |
376 | else | 378 | else |
@@ -386,12 +388,13 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); | @@ -386,12 +388,13 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); | ||
386 | 388 | ||
387 | lib3270_write_dstrace( | 389 | lib3270_write_dstrace( |
388 | ft->host, | 390 | ft->host, |
389 | - "\nSending file %s (%ld bytes %s %s %s)\n", | 391 | + "\nSending file %s (%ld bytes %s %s %s %s)\n", |
390 | ft->local, | 392 | ft->local, |
391 | ft->length, | 393 | ft->length, |
392 | - ft->ascii_flag ? "ASCII" : "BINARY", | ||
393 | - ft->cr_flag ? "CRLF" : "NOCRLF", | ||
394 | - ft->remap_flag ? "REMAP" : "NOREMAP" | 394 | + ft->ascii_flag ? "ASCII" : "BINARY", |
395 | + ft->cr_flag ? "CRLF" : "NOCRLF", | ||
396 | + ft->remap_flag ? "REMAP" : "NOREMAP", | ||
397 | + ft->unix_text ? "LF only" : "CR/LF" | ||
395 | ); | 398 | ); |
396 | 399 | ||
397 | rewind(ft->local_file); | 400 | rewind(ft->local_file); |
ft_cut.c
@@ -192,11 +192,12 @@ static int upload_convert(H3270 *hSession, unsigned char *buf, int len) | @@ -192,11 +192,12 @@ static int upload_convert(H3270 *hSession, unsigned char *buf, int len) | ||
192 | /* Map it. */ | 192 | /* Map it. */ |
193 | c = conv[ft->quadrant].xlate[ix]; | 193 | c = conv[ft->quadrant].xlate[ix]; |
194 | 194 | ||
195 | - if (ft->ascii_flag && ft->cr_flag && (c == '\r' || c == 0x1a)) | 195 | +// if (ft->ascii_flag && ft->cr_flag && (c == '\r' || c == 0x1a)) |
196 | + if (ft->unix_text && (c == '\r' || c == 0x1a)) | ||
196 | continue; | 197 | continue; |
197 | - | ||
198 | - if (ft->ascii_flag && ft->remap_flag) | 198 | + else if (ft->ascii_flag && ft->remap_flag) |
199 | c = ft->charset.ebc2asc[c]; | 199 | c = ft->charset.ebc2asc[c]; |
200 | + | ||
200 | *ob++ = c; | 201 | *ob++ = c; |
201 | } | 202 | } |
202 | 203 |
ft_dft.c
@@ -294,12 +294,15 @@ static void dft_data_insert(H3270 *hSession, struct data_buffer *data_bufr) | @@ -294,12 +294,15 @@ static void dft_data_insert(H3270 *hSession, struct data_buffer *data_bufr) | ||
294 | s++; | 294 | s++; |
295 | } | 295 | } |
296 | } | 296 | } |
297 | - if (ft->ascii_flag && ft->cr_flag) | 297 | + |
298 | +// if (ft->ascii_flag && ft->cr_flag) | ||
299 | + if (ft->unix_text) | ||
298 | { | 300 | { |
301 | + /* Delete CRs and ^Zs. */ | ||
302 | + | ||
299 | char *s = (char *)data_bufr->data; | 303 | char *s = (char *)data_bufr->data; |
300 | unsigned len = my_length; | 304 | unsigned len = my_length; |
301 | 305 | ||
302 | - /* Delete CRs and ^Zs. */ | ||
303 | while (len) { | 306 | while (len) { |
304 | unsigned l = filter_len(s, len); | 307 | unsigned l = filter_len(s, len); |
305 | 308 | ||
@@ -375,7 +378,7 @@ static void dft_get_request(H3270 *hSession) | @@ -375,7 +378,7 @@ static void dft_get_request(H3270 *hSession) | ||
375 | 378 | ||
376 | while (!ft->dft_eof && numbytes) | 379 | while (!ft->dft_eof && numbytes) |
377 | { | 380 | { |
378 | - if (ft->ascii_flag && ft->cr_flag) | 381 | + if (ft->unix_text) |
379 | { | 382 | { |
380 | // ASCII text file | 383 | // ASCII text file |
381 | 384 |