diff options
| author | Ulf Lilleengen <lulf@FreeBSD.org> | 2008-10-25 10:52:22 +0000 |
|---|---|---|
| committer | Ulf Lilleengen <lulf@FreeBSD.org> | 2008-10-25 10:52:22 +0000 |
| commit | 763db4b13875d56f6030e0b52248aec12a8ea1b8 (patch) | |
| tree | 56b10be85fae6b9372e3c715400a113ff1f7be44 | |
| parent | 92854d9d503c5ea24fdd22a470222e32d73a679f (diff) | |
Notes
| -rw-r--r-- | contrib/csup/proto.c | 20 | ||||
| -rw-r--r-- | contrib/csup/proto.h | 1 |
2 files changed, 21 insertions, 0 deletions
diff --git a/contrib/csup/proto.c b/contrib/csup/proto.c index 6c387fb53628..fd574b0fb790 100644 --- a/contrib/csup/proto.c +++ b/contrib/csup/proto.c @@ -950,6 +950,26 @@ proto_get_int(char **s, int *val, int base) } /* + * 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. * * Ideally, we would use an intmax_t and strtoimax() here, but strtoll() diff --git a/contrib/csup/proto.h b/contrib/csup/proto.h index ea9c01230232..0c4a78299f11 100644 --- a/contrib/csup/proto.h +++ b/contrib/csup/proto.h @@ -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_ */ |
