(recvline): Simplify parsing out output ids. Also tighten sanity
check some.
This commit is contained in:
parent
041c71de80
commit
f2542fcf7e
1 changed files with 3 additions and 10 deletions
|
@ -35,6 +35,7 @@
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -49,7 +50,6 @@ recvline(int s, char *buf)
|
||||||
int size;
|
int size;
|
||||||
char *p;
|
char *p;
|
||||||
int n;
|
int n;
|
||||||
int code;
|
|
||||||
int newline;
|
int newline;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
int cc;
|
int cc;
|
||||||
|
@ -123,18 +123,11 @@ recvline(int s, char *buf)
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
(void)alarm(0);
|
(void)alarm(0);
|
||||||
#endif
|
#endif
|
||||||
if (!isxdigit(*buf)) {
|
if (!isxdigit(buf[0]) || buf[1] != ' ') {
|
||||||
fprintf(stderr, "Malformed line %s\n", buf);
|
fprintf(stderr, "Malformed line %s\n", buf);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (isdigit(*buf))
|
return strtol(buf, NULL, 16);
|
||||||
code = *buf - '0';
|
|
||||||
else {
|
|
||||||
if (isupper(*buf))
|
|
||||||
*buf = tolower(*buf);
|
|
||||||
code = 10 + *buf - 'a';
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue