Commit 20a9ede920f29d64b0278f61cc4ce220f7714cfd
1 parent
ec0ba580
Exists in
master
and in
5 other branches
Download de arquivos texto precisa de tratamento diferente em windows (CR+LF & 0x1a no final).
Showing
6 changed files
with
63 additions
and
50 deletions
Show diff stats
Makefile.in
| @@ -299,6 +299,7 @@ $(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar: clean pixmaps | @@ -299,6 +299,7 @@ $(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar: clean pixmaps | ||
| 299 | @cp AUTHORS LICENSE $(TMPDIR)/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION) | 299 | @cp AUTHORS LICENSE $(TMPDIR)/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION) |
| 300 | @cp -r src $(TMPDIR)/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION) | 300 | @cp -r src $(TMPDIR)/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION) |
| 301 | @cp -r scripts $(TMPDIR)/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION) | 301 | @cp -r scripts $(TMPDIR)/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION) |
| 302 | + @cp -r nsi $(TMPDIR)/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION) | ||
| 302 | @cp $(PACKAGE_TARNAME).spec $(TMPDIR)/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION) | 303 | @cp $(PACKAGE_TARNAME).spec $(TMPDIR)/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION) |
| 303 | 304 | ||
| 304 | @cp debian.* $(TMPDIR)/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION) | 305 | @cp debian.* $(TMPDIR)/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION) |
src/include/lib3270/filetransfer.h
| @@ -37,32 +37,16 @@ | @@ -37,32 +37,16 @@ | ||
| 37 | #include <sys/time.h> | 37 | #include <sys/time.h> |
| 38 | #include <lib3270/charset.h> | 38 | #include <lib3270/charset.h> |
| 39 | 39 | ||
| 40 | - | ||
| 41 | -/* | ||
| 42 | - #define LIB3270_FT_RECORD_FORMAT_DEFAULT 0x0000 | ||
| 43 | - #define LIB3270_FT_RECORD_FORMAT_FIXED 0x0100 | ||
| 44 | - #define LIB3270_FT_RECORD_FORMAT_VARIABLE 0x0200 | ||
| 45 | - #define LIB3270_FT_RECORD_FORMAT_UNDEFINED 0x0300 | ||
| 46 | - #define LIB3270_FT_RECORD_FORMAT_MASK LIB3270_FT_RECORD_FORMAT_UNDEFINED | ||
| 47 | -*/ | ||
| 48 | - | ||
| 49 | -/* | ||
| 50 | - #define LIB3270_FT_ALLOCATION_UNITS_DEFAULT 0x0000 | ||
| 51 | - #define LIB3270_FT_ALLOCATION_UNITS_TRACKS 0x1000 | ||
| 52 | - #define LIB3270_FT_ALLOCATION_UNITS_CYLINDERS 0x2000 | ||
| 53 | - #define LIB3270_FT_ALLOCATION_UNITS_AVBLOCK 0x3000 | ||
| 54 | - #define LIB3270_FT_ALLOCATION_UNITS_MASK LIB3270_FT_ALLOCATION_UNITS_AVBLOCK | ||
| 55 | -*/ | ||
| 56 | - | ||
| 57 | typedef enum _lib3270_FT_OPTION | 40 | typedef enum _lib3270_FT_OPTION |
| 58 | { | 41 | { |
| 59 | LIB3270_FT_OPTION_SEND = 0x0000, | 42 | LIB3270_FT_OPTION_SEND = 0x0000, |
| 60 | 43 | ||
| 61 | LIB3270_FT_OPTION_RECEIVE = 0x0001, | 44 | LIB3270_FT_OPTION_RECEIVE = 0x0001, |
| 62 | - LIB3270_FT_OPTION_ASCII = 0x0002, /**< Convert to ascii */ | ||
| 63 | - LIB3270_FT_OPTION_CRLF = 0x0004, /**< Add crlf to each line */ | 45 | + LIB3270_FT_OPTION_ASCII = 0x0002, ///< @brief Convert to ascii |
| 46 | + LIB3270_FT_OPTION_CRLF = 0x0004, ///< @brief Add crlf to each line | ||
| 64 | LIB3270_FT_OPTION_APPEND = 0x0008, | 47 | LIB3270_FT_OPTION_APPEND = 0x0008, |
| 65 | - LIB3270_FT_OPTION_REMAP = 0x0010, /**< Remap ASCII<->EBCDIC */ | 48 | + LIB3270_FT_OPTION_REMAP = 0x0010, ///< @brief Remap ASCII<->EBCDIC |
| 49 | + LIB3270_FT_OPTION_UNIX = 0x0020, ///< @brief Unix text file | ||
| 66 | 50 | ||
| 67 | LIB3270_FT_RECORD_FORMAT_DEFAULT = 0x0000, | 51 | LIB3270_FT_RECORD_FORMAT_DEFAULT = 0x0000, |
| 68 | LIB3270_FT_RECORD_FORMAT_FIXED = 0x0100, | 52 | LIB3270_FT_RECORD_FORMAT_FIXED = 0x0100, |
| @@ -92,21 +76,22 @@ | @@ -92,21 +76,22 @@ | ||
| 92 | 76 | ||
| 93 | typedef struct _h3270ft | 77 | typedef struct _h3270ft |
| 94 | { | 78 | { |
| 95 | - unsigned short sz; /**< Size of FT data structure */ | ||
| 96 | - | ||
| 97 | - int ft_last_cr : 1; /**< CR was last char in local file */ | ||
| 98 | - int remap_flag : 1; /**< Remap ASCII<->EBCDIC */ | ||
| 99 | - int cr_flag : 1; | ||
| 100 | - int message_flag : 1; /**< Open Request for msg received */ | ||
| 101 | - int ascii_flag : 1; /**< Convert to ascii */ | ||
| 102 | - int ft_is_cut : 1; /**< File transfer is CUT-style */ | 79 | + unsigned short sz; ///< @brief Size of FT data structure |
| 80 | + | ||
| 81 | + int ft_last_cr : 1; ///< @brief CR was last char in local file | ||
| 82 | + int remap_flag : 1; ///< @brief Remap ASCII<->EBCDIC | ||
| 83 | + int cr_flag : 1; ///< @brief Add crlf to each line | ||
| 84 | + int unix_text : 1; ///< @brief Following the convention for UNIX text files. | ||
| 85 | + int message_flag : 1; ///< @brief Open Request for msg received | ||
| 86 | + int ascii_flag : 1; ///< @brief Convert to ascii | ||
| 87 | + int ft_is_cut : 1; ///< @brief File transfer is CUT-style | ||
| 103 | int dft_eof : 1; | 88 | int dft_eof : 1; |
| 104 | 89 | ||
| 105 | 90 | ||
| 106 | H3270 * host; | 91 | H3270 * host; |
| 107 | - void * widget; /**< File transfer dialog handle */ | ||
| 108 | - FILE * local_file; /**< File descriptor for local file */ | ||
| 109 | - unsigned long length; /**< File length */ | 92 | + void * widget; ///< @brief File transfer dialog handle |
| 93 | + FILE * local_file; ///< @brief File descriptor for local file | ||
| 94 | + unsigned long length; ///< @brief File length | ||
| 110 | 95 | ||
| 111 | LIB3270_FT_STATE state; | 96 | LIB3270_FT_STATE state; |
| 112 | LIB3270_FT_OPTION flags; | 97 | LIB3270_FT_OPTION flags; |
src/lib3270/ft.c
| @@ -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); |
src/lib3270/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 |
src/lib3270/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 |
src/pw3270/ft/ftdialog.c
| @@ -375,8 +375,12 @@ GtkWidget * v3270_ft_dialog_new(GtkWidget *parent, LIB3270_FT_OPTION options) | @@ -375,8 +375,12 @@ GtkWidget * v3270_ft_dialog_new(GtkWidget *parent, LIB3270_FT_OPTION options) | ||
| 375 | { | 375 | { |
| 376 | LIB3270_FT_OPTION_CRLF, | 376 | LIB3270_FT_OPTION_CRLF, |
| 377 | BUTTON_CRLF, | 377 | BUTTON_CRLF, |
| 378 | - N_( "Remove <_CR> from end of the line." ), | ||
| 379 | - N_( "Following the convention for LINUX text files, <LF> are used to terminate records in the PC file.") | 378 | + N_( "Follow the convention for ASCII text files." ), |
| 379 | +#ifdef _WIN32 | ||
| 380 | + N_( "Following the convention for ASCII text files, <CR> <LF> pairs are used to terminate records in the PC file, and a CTRL-Z (x'1A') marks the end of file.") | ||
| 381 | +#else | ||
| 382 | + N_( "Following the convention for ASCII text files, <LF> is used to terminate records in the PC file.") | ||
| 383 | +#endif // _WIN32 | ||
| 380 | }, | 384 | }, |
| 381 | { | 385 | { |
| 382 | LIB3270_FT_OPTION_APPEND, | 386 | LIB3270_FT_OPTION_APPEND, |
| @@ -465,8 +469,12 @@ GtkWidget * v3270_ft_dialog_new(GtkWidget *parent, LIB3270_FT_OPTION options) | @@ -465,8 +469,12 @@ GtkWidget * v3270_ft_dialog_new(GtkWidget *parent, LIB3270_FT_OPTION options) | ||
| 465 | { | 469 | { |
| 466 | LIB3270_FT_OPTION_CRLF, | 470 | LIB3270_FT_OPTION_CRLF, |
| 467 | BUTTON_CRLF, | 471 | BUTTON_CRLF, |
| 468 | - N_( "Add <CR> at end of the line." ), | ||
| 469 | - N_( "Add an extra <CR> to follow the convention for ASCII text files.") | 472 | + N_( "Follow the convention for ASCII text files." ), |
| 473 | +#ifdef _WIN32 | ||
| 474 | + N_( "Following the convention for ASCII text files, <CR> <LF> pairs are used to terminate records in the PC file, and a CTRL-Z (x'1A') marks the end of file.") | ||
| 475 | +#else | ||
| 476 | + N_( "Following the convention for ASCII text files, <LF> is used to terminate records in the PC file.") | ||
| 477 | +#endif // _WIN32 | ||
| 470 | }, | 478 | }, |
| 471 | { | 479 | { |
| 472 | LIB3270_FT_OPTION_APPEND, | 480 | LIB3270_FT_OPTION_APPEND, |
| @@ -689,8 +697,20 @@ const gchar * v3270_ft_dialog_get_local_filename(GtkWidget *widget) | @@ -689,8 +697,20 @@ const gchar * v3270_ft_dialog_get_local_filename(GtkWidget *widget) | ||
| 689 | 697 | ||
| 690 | LIB3270_FT_OPTION v3270_ft_dialog_get_options(GtkWidget *widget) | 698 | LIB3270_FT_OPTION v3270_ft_dialog_get_options(GtkWidget *widget) |
| 691 | { | 699 | { |
| 700 | + LIB3270_FT_OPTION opt; | ||
| 701 | + | ||
| 692 | g_return_val_if_fail(GTK_IS_V3270FTD(widget),0); | 702 | g_return_val_if_fail(GTK_IS_V3270FTD(widget),0); |
| 693 | - return GTK_V3270FTD(widget)->options; | 703 | + |
| 704 | + opt = GTK_V3270FTD(widget)->options; | ||
| 705 | + | ||
| 706 | +#ifndef _WIN32 | ||
| 707 | + if( (opt & (LIB3270_FT_OPTION_ASCII|LIB3270_FT_OPTION_CRLF)) == (LIB3270_FT_OPTION_ASCII|LIB3270_FT_OPTION_CRLF) ) | ||
| 708 | + { | ||
| 709 | + opt |= LIB3270_FT_OPTION_UNIX; | ||
| 710 | + } | ||
| 711 | +#endif // _WIN32 | ||
| 712 | + | ||
| 713 | + return opt; | ||
| 694 | } | 714 | } |
| 695 | 715 | ||
| 696 | void v3270_ft_dialog_set_options(GtkWidget *widget,LIB3270_FT_OPTION options) | 716 | void v3270_ft_dialog_set_options(GtkWidget *widget,LIB3270_FT_OPTION options) |