Changeset 3232 in MondoRescue for branches/3.2/mindi-busybox/miscutils/rx.c
- Timestamp:
- Jan 1, 2014, 12:47:38 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/mindi-busybox/miscutils/rx.c
r2725 r3232 15 15 * This was originally written for blob and then adapted for busybox. 16 16 */ 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" 17 25 18 26 #include "libbb.h" … … 101 109 } 102 110 /* 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; 109 115 } 110 116 … … 148 154 } 149 155 156 cksum_or_crc = read_byte(TIMEOUT); 157 if (cksum_or_crc < 0) 158 goto timeout; 150 159 if (do_crc) { 151 cksum_or_crc = read_byte(TIMEOUT);152 if (cksum_or_crc < 0)153 goto timeout;154 160 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);159 161 if (cksum_or_crc < 0) 160 162 goto timeout; … … 165 167 /* this also ignores the initial block 0 which is */ 166 168 /* meta data. */ 169 blockLength = 0; 167 170 goto next; 168 171 } … … 191 194 if (cksum_or_crc != expected) { 192 195 bb_error_msg(do_crc ? "crc error, expected 0x%04x, got 0x%04x" 193 194 196 : "checksum error, expected 0x%02x, got 0x%02x", 197 expected, cksum_or_crc); 195 198 goto error; 196 199 } … … 205 208 error: 206 209 timeout: 210 blockLength = 0; 207 211 errors++; 208 212 if (errors == MAXERRORS) {
Note:
See TracChangeset
for help on using the changeset viewer.