- Implement support for retrieving a size_t type from the protocol stream.

This commit is contained in:
Ulf Lilleengen 2008-10-25 10:52:22 +00:00
parent 92854d9d50
commit 763db4b138
2 changed files with 21 additions and 0 deletions

View File

@ -949,6 +949,26 @@ proto_get_int(char **s, int *val, int base)
return (error);
}
/*
* Get a size_t token.
*/
int
proto_get_sizet(char **s, size_t *val, int base)
{
unsigned long long tmp;
char *cp, *end;
cp = proto_get_ascii(s);
if (cp == NULL)
return (-1);
errno = 0;
tmp = strtoll(cp, &end, base);
if (errno || *end != '\0')
return (-1);
*val = (size_t)tmp;
return (0);
}
/*
* Get a time_t token.
*

View File

@ -44,6 +44,7 @@ int proto_printf(struct stream *, const char *, ...);
char *proto_get_ascii(char **);
char *proto_get_rest(char **);
int proto_get_int(char **, int *, int);
int proto_get_sizet(char **, size_t *, int);
int proto_get_time(char **, time_t *);
#endif /* !_PROTO_H_ */