aboutsummaryrefslogtreecommitdiff
path: root/miscutils/rx.c
diff options
context:
space:
mode:
authorGravatar Rob Landley <rob@landley.net>2006-06-21 01:49:17 +0000
committerGravatar Rob Landley <rob@landley.net>2006-06-21 01:49:17 +0000
commit399d45f1c6ecfedac9801978b6ec85239142ed8d (patch)
tree79117d78dcf9c3eddae4aefed235d3a61d23498f /miscutils/rx.c
parente5e1a10cd32e94ccd1031de98c25ed7ba2853e29 (diff)
downloadbusybox-399d45f1c6ecfedac9801978b6ec85239142ed8d.tar.gz
busybox-399d45f1c6ecfedac9801978b6ec85239142ed8d.tar.bz2
Aurelien Jacobs pointed out inline functions that could be removed. Doing so
shrank the code a bit.
Diffstat (limited to 'miscutils/rx.c')
-rw-r--r--miscutils/rx.c42
1 files changed, 13 insertions, 29 deletions
diff --git a/miscutils/rx.c b/miscutils/rx.c
index 7642094b7..cff5a627b 100644
--- a/miscutils/rx.c
+++ b/miscutils/rx.c
@@ -39,7 +39,6 @@
#define EOT 0x04
#define ACK 0x06
#define NAK 0x15
-#define CAN 0x18
#define BS 0x08
/*
@@ -57,18 +56,6 @@ Cf:
#define TIMEOUT_LONG 10
#define MAXERRORS 10
-static inline void write_byte(int fd, char cc) {
- write(fd, &cc, 1);
-}
-
-static inline void write_flush(int fd) {
- tcdrain(fd);
-}
-
-static inline void read_flush(int fd) {
- tcflush(fd, TCIFLUSH);
-}
-
static int read_byte(int fd, unsigned int timeout) {
char buf[1];
int n;
@@ -99,11 +86,11 @@ static int receive(char *error_buf, size_t error_buf_size,
#define note_error(fmt,args...) \
snprintf(error_buf, error_buf_size, fmt,##args)
- read_flush(ttyfd);
+ /* Flush pending input */
+ tcflush(ttyfd, TCIFLUSH);
/* Ask for CRC; if we get errors, we will go with checksum */
- write_byte(ttyfd, nak);
- write_flush(ttyfd);
+ write(ttyfd, &nak, 1);
for (;;) {
int blockBegin;
@@ -126,8 +113,8 @@ static int receive(char *error_buf, size_t error_buf_size,
break;
case EOT:
- write_byte(ttyfd, ACK);
- write_flush(ttyfd);
+ nak = ACK;
+ write(ttyfd, &nak, 1);
goto done;
default:
@@ -232,8 +219,8 @@ static int receive(char *error_buf, size_t error_buf_size,
next:
errors = 0;
- write_byte(ttyfd, ACK);
- write_flush(ttyfd);
+ nak = ACK;
+ write(ttyfd, &nak, 1);
continue;
error:
@@ -241,7 +228,6 @@ static int receive(char *error_buf, size_t error_buf_size,
errors++;
if (errors == MAXERRORS) {
/* Abort */
- int i;
// if using crc, try again w/o crc
if (nak == 'C') {
@@ -254,17 +240,15 @@ static int receive(char *error_buf, size_t error_buf_size,
note_error("too many errors; giving up");
fatal:
- for (i = 0; i < 5; i ++)
- write_byte(ttyfd, CAN);
- for (i = 0; i < 5; i ++)
- write_byte(ttyfd, BS);
- write_flush(ttyfd);
+ /* 5 CAN followed by 5 BS */
+ write(ttyfd, "\030\030\030\030\030\010\010\010\010\010", 10);
return -1;
}
- read_flush(ttyfd);
- write_byte(ttyfd, nak);
- write_flush(ttyfd);
+ /* Flush pending input */
+ tcflush(ttyfd, TCIFLUSH);
+
+ write(ttyfd, &nak, 1);
}
done: