(recvline): Cope with multiple-digit ids. Server doesn't send such
ids at this time.
This commit is contained in:
parent
8cdf2532d4
commit
c9c9305c2f
1 changed files with 10 additions and 5 deletions
|
@ -45,6 +45,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
#include "proto.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define read(sock, buffer, buf_size) \
|
#define read(sock, buffer, buf_size) \
|
||||||
|
@ -57,9 +58,10 @@ int
|
||||||
recvline(int s, char *buf)
|
recvline(int s, char *buf)
|
||||||
{
|
{
|
||||||
int sz = 1024;
|
int sz = 1024;
|
||||||
char *bp;
|
char *bp, *end;
|
||||||
char ch;
|
char ch;
|
||||||
ssize_t n;
|
ssize_t n;
|
||||||
|
long id;
|
||||||
|
|
||||||
bp = buf;
|
bp = buf;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@ -83,11 +85,14 @@ recvline(int s, char *buf)
|
||||||
*bp++ = ch;
|
*bp++ = ch;
|
||||||
*bp = 0;
|
*bp = 0;
|
||||||
|
|
||||||
if (!isxdigit(buf[0]) || buf[1] != ' ') {
|
id = strtol(buf, &end, 16);
|
||||||
fprintf(stderr, "Malformed line %s\n", buf);
|
if (end == buf || *end != ' ') {
|
||||||
return 0;
|
fprintf(stderr, "Malformed id in line %s", buf);
|
||||||
|
id = -1;
|
||||||
}
|
}
|
||||||
return strtol(buf, NULL, 16);
|
if (id > C_LAST)
|
||||||
|
id = -1;
|
||||||
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue