That'll work, I suppose
This commit is contained in:
parent
17dd963f97
commit
b5ef56c4a0
1 changed files with 9 additions and 3 deletions
12
src/kiss.c
12
src/kiss.c
|
@ -10,6 +10,10 @@ ssize_t patty_kiss_read(int fd, void *buf, size_t len, int *port) {
|
||||||
int flags = KISS_NONE;
|
int flags = KISS_NONE;
|
||||||
size_t i, b = 0;
|
size_t i, b = 0;
|
||||||
|
|
||||||
|
if (read(fd, buf, len) < 0) {
|
||||||
|
goto error_io;
|
||||||
|
}
|
||||||
|
|
||||||
*port = 0;
|
*port = 0;
|
||||||
|
|
||||||
for (i=0; i<len; i++) {
|
for (i=0; i<len; i++) {
|
||||||
|
@ -25,10 +29,12 @@ ssize_t patty_kiss_read(int fd, void *buf, size_t len, int *port) {
|
||||||
|
|
||||||
if (flags & KISS_ESCAPE) {
|
if (flags & KISS_ESCAPE) {
|
||||||
if (c == PATTY_KISS_TFEND) {
|
if (c == PATTY_KISS_TFEND) {
|
||||||
((char *)buf)[b++] = PATTY_KISS_FEND;
|
((unsigned char *)buf)[b++] = PATTY_KISS_FEND;
|
||||||
} else if (c == PATTY_KISS_TFESC) {
|
} else if (c == PATTY_KISS_TFESC) {
|
||||||
((char *)buf)[b++] = PATTY_KISS_FESC;
|
((unsigned char *)buf)[b++] = PATTY_KISS_FESC;
|
||||||
} else {
|
} else {
|
||||||
|
errno = EIO;
|
||||||
|
|
||||||
goto error_io;
|
goto error_io;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +66,7 @@ ssize_t patty_kiss_read(int fd, void *buf, size_t len, int *port) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
((char *)buf)[b++] = c;
|
((unsigned char *)buf)[b++] = c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue