Commit 4b647f996b520943832ece617a55132c6d3308da
1 parent
8df67fe2
Exists in
master
and in
5 other branches
Trabalhando no bug relativo à transferência de arquivos binários
Showing
1 changed file
with
21 additions
and
8 deletions
Show diff stats
src/lib3270/ft_dft.c
@@ -391,16 +391,20 @@ static void dft_get_request(H3270 *hSession) | @@ -391,16 +391,20 @@ static void dft_get_request(H3270 *hSession) | ||
391 | { | 391 | { |
392 | if (ft->ascii_flag && ft->cr_flag) | 392 | if (ft->ascii_flag && ft->cr_flag) |
393 | { | 393 | { |
394 | + // ASCII text file | ||
395 | + | ||
394 | int c; | 396 | int c; |
395 | 397 | ||
396 | /* Read one byte and do CR/LF translation. */ | 398 | /* Read one byte and do CR/LF translation. */ |
397 | c = fgetc(ft->local_file); | 399 | c = fgetc(ft->local_file); |
398 | - if (c == EOF) { | 400 | + if (c == EOF) |
401 | + { | ||
399 | break; | 402 | break; |
400 | } | 403 | } |
401 | if (!ft->ft_last_cr && c == '\n') | 404 | if (!ft->ft_last_cr && c == '\n') |
402 | { | 405 | { |
403 | - if (numbytes < 2) { | 406 | + if (numbytes < 2) |
407 | + { | ||
404 | /* | 408 | /* |
405 | * Not enough room to expand NL to | 409 | * Not enough room to expand NL to |
406 | * CR/LF. | 410 | * CR/LF. |
@@ -416,14 +420,20 @@ static void dft_get_request(H3270 *hSession) | @@ -416,14 +420,20 @@ static void dft_get_request(H3270 *hSession) | ||
416 | *bufptr++ = ft->remap_flag ? ft->charset.asc2ebc[c]: c; | 420 | *bufptr++ = ft->remap_flag ? ft->charset.asc2ebc[c]: c; |
417 | numbytes--; | 421 | numbytes--; |
418 | total_read++; | 422 | total_read++; |
419 | - } else { | 423 | + } |
424 | + else | ||
425 | + { | ||
420 | /* Binary read. */ | 426 | /* Binary read. */ |
421 | numread = fread(bufptr, 1, numbytes, ft->local_file); | 427 | numread = fread(bufptr, 1, numbytes, ft->local_file); |
422 | - if (numread <= 0) { | 428 | + if (numread <= 0) |
429 | + { | ||
430 | + lib3270_write_log(hSession,"Error %s reading source file (rc=%d)",strerror(errno),errno); | ||
423 | break; | 431 | break; |
424 | } | 432 | } |
433 | + | ||
425 | if (ft->ascii_flag && ft->remap_flag) | 434 | if (ft->ascii_flag && ft->remap_flag) |
426 | { | 435 | { |
436 | + // Remap charset | ||
427 | unsigned char *s = bufptr; | 437 | unsigned char *s = bufptr; |
428 | int i = numread; | 438 | int i = numread; |
429 | 439 | ||
@@ -434,10 +444,11 @@ static void dft_get_request(H3270 *hSession) | @@ -434,10 +444,11 @@ static void dft_get_request(H3270 *hSession) | ||
434 | i--; | 444 | i--; |
435 | } | 445 | } |
436 | } | 446 | } |
437 | - bufptr += numread; | ||
438 | - numbytes -= numread; | ||
439 | - total_read += numread; | 447 | + bufptr += numread; |
448 | + numbytes -= numread; | ||
449 | + total_read += numread; | ||
440 | } | 450 | } |
451 | + | ||
441 | if (feof(ft->local_file) || ferror(ft->local_file)) | 452 | if (feof(ft->local_file) || ferror(ft->local_file)) |
442 | { | 453 | { |
443 | break; | 454 | break; |
@@ -476,7 +487,9 @@ static void dft_get_request(H3270 *hSession) | @@ -476,7 +487,9 @@ static void dft_get_request(H3270 *hSession) | ||
476 | ft->dft_eof = 1; | 487 | ft->dft_eof = 1; |
477 | } | 488 | } |
478 | 489 | ||
479 | - } else { | 490 | + } |
491 | + else | ||
492 | + { | ||
480 | trace_ds(hSession,"> WriteStructuredField FileTransferData EOF\n"); | 493 | trace_ds(hSession,"> WriteStructuredField FileTransferData EOF\n"); |
481 | *hSession->obptr++ = HIGH8(TR_GET_REQ); | 494 | *hSession->obptr++ = HIGH8(TR_GET_REQ); |
482 | *hSession->obptr++ = TR_ERROR_REPLY; | 495 | *hSession->obptr++ = TR_ERROR_REPLY; |