Ignore:
Timestamp:
Jan 1, 2014, 12:47:38 AM (7 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.21.1
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/mindi-busybox/miscutils/rx.c

    r2725 r3232  
    1515 * This was originally written for blob and then adapted for busybox.
    1616 */
     17
     18//usage:#define rx_trivial_usage
     19//usage:       "FILE"
     20//usage:#define rx_full_usage "\n\n"
     21//usage:       "Receive a file using the xmodem protocol"
     22//usage:
     23//usage:#define rx_example_usage
     24//usage:       "$ rx /tmp/foo\n"
    1725
    1826#include "libbb.h"
     
    101109        }
    102110        /* Write previously received block */
    103         if (blockLength) {
    104             errno = 0;
    105             if (full_write(file_fd, blockBuf, blockLength) != blockLength) {
    106                 bb_perror_msg("can't write to file");
    107                 goto fatal;
    108             }
     111        errno = 0;
     112        if (full_write(file_fd, blockBuf, blockLength) != blockLength) {
     113            bb_perror_msg(bb_msg_write_error);
     114            goto fatal;
    109115        }
    110116
     
    148154        }
    149155
     156        cksum_or_crc = read_byte(TIMEOUT);
     157        if (cksum_or_crc < 0)
     158            goto timeout;
    150159        if (do_crc) {
    151             cksum_or_crc = read_byte(TIMEOUT);
    152             if (cksum_or_crc < 0)
    153                 goto timeout;
    154160            cksum_or_crc = (cksum_or_crc << 8) | read_byte(TIMEOUT);
    155             if (cksum_or_crc < 0)
    156                 goto timeout;
    157         } else {
    158             cksum_or_crc = read_byte(TIMEOUT);
    159161            if (cksum_or_crc < 0)
    160162                goto timeout;
     
    165167            /* this also ignores the initial block 0 which is */
    166168            /* meta data. */
     169            blockLength = 0;
    167170            goto next;
    168171        }
     
    191194        if (cksum_or_crc != expected) {
    192195            bb_error_msg(do_crc ? "crc error, expected 0x%04x, got 0x%04x"
    193                                : "checksum error, expected 0x%02x, got 0x%02x",
    194                     expected, cksum_or_crc);
     196                    : "checksum error, expected 0x%02x, got 0x%02x",
     197                expected, cksum_or_crc);
    195198            goto error;
    196199        }
     
    205208 error:
    206209 timeout:
     210        blockLength = 0;
    207211        errors++;
    208212        if (errors == MAXERRORS) {
Note: See TracChangeset for help on using the changeset viewer.