Commit 5d80a5c34473c1b2705d40b124a3dc4469c0740f
1 parent
14285d75
Exists in
master
and in
3 other branches
Corrigindo opções da transferência de arquivos
Showing
4 changed files
with
48 additions
and
27 deletions
Show diff stats
charset.c
| ... | ... | @@ -132,6 +132,7 @@ static const unsigned short asc2ebc0[256] = |
| 132 | 132 | /*f8*/ 0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf |
| 133 | 133 | }; |
| 134 | 134 | |
| 135 | +/* | |
| 135 | 136 | static const unsigned short ft2asc[256] = |
| 136 | 137 | { |
| 137 | 138 | 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] = |
| 171 | 172 | 0xa3,0xa4,0xa1,0xa5,0xa2,0xa6,0xcd,0xa7,0xac,0xa9,0xaa,0xab,0xb0,0xad,0xae,0xaf, |
| 172 | 173 | 0xc6,0xa8,0xeb,0xec,0xe9,0xed,0xea,0x9f,0xba,0xf1,0xf2,0xef,0xf0,0xc7,0xc8,0xf3 |
| 173 | 174 | }; |
| 175 | +*/ | |
| 174 | 176 | |
| 175 | 177 | static const unsigned short asc2uc[UT_SIZE] = |
| 176 | 178 | { |
| ... | ... | @@ -271,10 +273,12 @@ LIB3270_EXPORT int lib3270_set_host_charset(H3270 *hSession, const char *name) |
| 271 | 273 | hSession->charset.asc2uc[f] = f; |
| 272 | 274 | copy_charset(asc2uc,hSession->charset.asc2uc); |
| 273 | 275 | |
| 276 | +/* | |
| 274 | 277 | #if defined(X3270_FT) |
| 275 | 278 | memcpy(hSession->charset.ft2asc, ft2asc, sizeof(hSession->charset.ft2asc)); |
| 276 | 279 | memcpy(hSession->charset.asc2ft, asc2ft, sizeof(hSession->charset.asc2ft)); |
| 277 | 280 | #endif |
| 281 | +*/ | |
| 278 | 282 | |
| 279 | 283 | if(!(name && strcasecmp(name,hSession->charset.host))) |
| 280 | 284 | return 0; |
| ... | ... | @@ -451,9 +455,9 @@ LIB3270_EXPORT void lib3270_remap(H3270 *hSession, unsigned short ebc, unsigned |
| 451 | 455 | |
| 452 | 456 | if (iso <= 0xff) |
| 453 | 457 | { |
| 454 | -#if defined(X3270_FT) | |
| 455 | - unsigned char aa; | |
| 456 | -#endif | |
| 458 | +//#if defined(X3270_FT) | |
| 459 | +// unsigned char aa; | |
| 460 | +//#endif | |
| 457 | 461 | |
| 458 | 462 | if (scope == BOTH || scope == CS_ONLY) |
| 459 | 463 | { |
| ... | ... | @@ -484,6 +488,8 @@ LIB3270_EXPORT void lib3270_remap(H3270 *hSession, unsigned short ebc, unsigned |
| 484 | 488 | hSession->charset.asc2ebc[iso] = ebc; |
| 485 | 489 | } |
| 486 | 490 | } |
| 491 | + | |
| 492 | +/* | |
| 487 | 493 | #if defined(X3270_FT) |
| 488 | 494 | if (iso <= 0xff && ebc > 0x40) |
| 489 | 495 | { |
| ... | ... | @@ -522,14 +528,8 @@ LIB3270_EXPORT void lib3270_remap(H3270 *hSession, unsigned short ebc, unsigned |
| 522 | 528 | } |
| 523 | 529 | } |
| 524 | 530 | #endif |
| 525 | - } | |
| 526 | -/* | |
| 527 | - else | |
| 528 | - { | |
| 529 | - // Auto-keymap. | |
| 530 | - add_xk(iso, (KeySym)hSession->charset.ebc2asc[ebc]); | |
| 531 | - } | |
| 532 | 531 | */ |
| 532 | + } | |
| 533 | 533 | } |
| 534 | 534 | |
| 535 | 535 | ... | ... |
| ... | ... | @@ -210,9 +210,10 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); |
| 210 | 210 | ftHandle->host = session; |
| 211 | 211 | |
| 212 | 212 | ftHandle->ft_last_cr = 0; |
| 213 | - ftHandle->remap_flag = 1; // Remap ASCII<->EBCDIC | |
| 214 | - ftHandle->cr_flag = 1; | |
| 215 | - ftHandle->ascii_flag = 1; | |
| 213 | + | |
| 214 | + ftHandle->ascii_flag = (flags & LIB3270_FT_OPTION_ASCII) ? 1 : 0; | |
| 215 | + ftHandle->cr_flag = (flags & LIB3270_FT_OPTION_CRLF) ? 1 : 0; | |
| 216 | + ftHandle->remap_flag = (flags & LIB3270_FT_OPTION_REMAP) ? 1 : 0; | |
| 216 | 217 | ftHandle->ft_is_cut = 0; |
| 217 | 218 | ftHandle->flags = flags; |
| 218 | 219 | ftHandle->local_file = ft_local_file; |
| ... | ... | @@ -230,6 +231,7 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); |
| 230 | 231 | ftHandle->dft = dft; |
| 231 | 232 | ftHandle->quadrant = -1; |
| 232 | 233 | |
| 234 | + memcpy(&ftHandle->charset,&session->charset,sizeof(struct lib3270_charset)); | |
| 233 | 235 | |
| 234 | 236 | ftHandle->local = (char *) (ftHandle+1); |
| 235 | 237 | strcpy((char *) ftHandle->local,local); |
| ... | ... | @@ -239,6 +241,8 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); |
| 239 | 241 | |
| 240 | 242 | session->ft = ftHandle; |
| 241 | 243 | |
| 244 | + | |
| 245 | + | |
| 242 | 246 | return ftHandle; |
| 243 | 247 | } |
| 244 | 248 | |
| ... | ... | @@ -260,16 +264,23 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); |
| 260 | 264 | if(!ft) |
| 261 | 265 | return EINVAL; |
| 262 | 266 | |
| 263 | - recfm = (ft->flags & FT_RECORD_FORMAT_MASK) >> 8; | |
| 264 | - units = (ft->flags & FT_ALLOCATION_UNITS_MASK) >> 12; | |
| 265 | - ft->ascii_flag = ((ft->flags & LIB3270_FT_OPTION_ASCII) == 0) ? 1 : 0; | |
| 266 | - ft->cr_flag = ((ft->flags & LIB3270_FT_OPTION_CRLF) == 0) ? 1 : 0; | |
| 267 | - ft->remap_flag = ((ft->flags & LIB3270_FT_OPTION_ASCII) == 0) ? 1 : 0; | |
| 267 | + recfm = (ft->flags & FT_RECORD_FORMAT_MASK) >> 8; | |
| 268 | + units = (ft->flags & FT_ALLOCATION_UNITS_MASK) >> 12; | |
| 269 | + ft->ascii_flag = (ft->flags & LIB3270_FT_OPTION_ASCII) ? 1 : 0; | |
| 270 | + ft->cr_flag = (ft->flags & LIB3270_FT_OPTION_CRLF) ? 1 : 0; | |
| 271 | + ft->remap_flag = (ft->flags & LIB3270_FT_OPTION_REMAP) ? 1 : 0; | |
| 268 | 272 | |
| 269 | 273 | if(ft->flags & LIB3270_FT_OPTION_RECEIVE) |
| 270 | 274 | { |
| 271 | 275 | // Receiving file |
| 272 | - lib3270_write_log(ft->host,"ft","Receiving file %s",ft->local); | |
| 276 | + lib3270_write_log( ft->host, | |
| 277 | + "ft", | |
| 278 | + "Receiving file %s %s %s %s", | |
| 279 | + ft->local, | |
| 280 | + ft->ascii_flag ? "ASCII" : "BINARY", | |
| 281 | + ft->cr_flag ? "CRLF" : "NOCRLF", | |
| 282 | + ft->remap_flag ? "REMAP" : "NOREMAP" | |
| 283 | + ); | |
| 273 | 284 | } |
| 274 | 285 | else |
| 275 | 286 | { |
| ... | ... | @@ -283,7 +294,15 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); |
| 283 | 294 | ft->length = ftell(ft->local_file); |
| 284 | 295 | |
| 285 | 296 | |
| 286 | - lib3270_write_log(ft->host,"ft","Sending file %s (%ld bytes)",ft->local,ft->length); | |
| 297 | + lib3270_write_log( ft->host, | |
| 298 | + "ft", | |
| 299 | + "Sending file %s (%ld bytes) %s %s %s", | |
| 300 | + ft->local, | |
| 301 | + ft->length, | |
| 302 | + ft->ascii_flag ? "ASCII" : "BINARY", | |
| 303 | + ft->cr_flag ? "CRLF" : "NOCRLF", | |
| 304 | + ft->remap_flag ? "REMAP" : "NOREMAP" | |
| 305 | + ); | |
| 287 | 306 | rewind(ft->local_file); |
| 288 | 307 | } |
| 289 | 308 | ... | ... |
ft_cut.c
| ... | ... | @@ -194,7 +194,7 @@ static int upload_convert(H3270 *hSession, unsigned char *buf, int len) |
| 194 | 194 | if (ft->ascii_flag && ft->cr_flag && (c == '\r' || c == 0x1a)) |
| 195 | 195 | continue; |
| 196 | 196 | if (ft->ascii_flag && ft->remap_flag) |
| 197 | - c = hSession->charset.ft2asc[c]; | |
| 197 | + c = ft->charset.ebc2asc[c]; | |
| 198 | 198 | *ob++ = c; |
| 199 | 199 | } |
| 200 | 200 | |
| ... | ... | @@ -231,7 +231,7 @@ static int download_convert(H3270FT *ft, unsigned const char *buf, unsigned len, |
| 231 | 231 | |
| 232 | 232 | /* Translate. */ |
| 233 | 233 | if (ft->ascii_flag && ft->remap_flag) |
| 234 | - c = hSession->charset.asc2ft[c]; | |
| 234 | + c = ft->charset.asc2ebc[c]; | |
| 235 | 235 | |
| 236 | 236 | /* Quadrant already defined. */ |
| 237 | 237 | if (ft->quadrant >= 0) { | ... | ... |
ft_dft.c
| ... | ... | @@ -304,7 +304,7 @@ static void dft_data_insert(H3270 *hSession, struct data_buffer *data_bufr) |
| 304 | 304 | |
| 305 | 305 | while (len--) |
| 306 | 306 | { |
| 307 | - *s = hSession->charset.ft2asc[*s]; | |
| 307 | + *s = ft->charset.ebc2asc[*s]; | |
| 308 | 308 | s++; |
| 309 | 309 | } |
| 310 | 310 | } |
| ... | ... | @@ -413,7 +413,7 @@ static void dft_get_request(H3270 *hSession) |
| 413 | 413 | total_read++; |
| 414 | 414 | } |
| 415 | 415 | ft->ft_last_cr = (c == '\r') ? 1 : 0; |
| 416 | - *bufptr++ = ft->remap_flag? hSession->charset.asc2ft[c]: c; | |
| 416 | + *bufptr++ = ft->remap_flag ? ft->charset.asc2ebc[c]: c; | |
| 417 | 417 | numbytes--; |
| 418 | 418 | total_read++; |
| 419 | 419 | } else { |
| ... | ... | @@ -422,12 +422,14 @@ static void dft_get_request(H3270 *hSession) |
| 422 | 422 | if (numread <= 0) { |
| 423 | 423 | break; |
| 424 | 424 | } |
| 425 | - if (ft->ascii_flag && ft->remap_flag) { | |
| 425 | + if (ft->ascii_flag && ft->remap_flag) | |
| 426 | + { | |
| 426 | 427 | unsigned char *s = bufptr; |
| 427 | 428 | int i = numread; |
| 428 | 429 | |
| 429 | - while (i) { | |
| 430 | - *s = hSession->charset.asc2ft[*s]; | |
| 430 | + while (i) | |
| 431 | + { | |
| 432 | + *s = ft->charset.asc2ebc[*s]; | |
| 431 | 433 | s++; |
| 432 | 434 | i--; |
| 433 | 435 | } | ... | ... |