diff options
| author | Maxime Henrion <mux@FreeBSD.org> | 2006-03-14 03:51:13 +0000 |
|---|---|---|
| committer | Maxime Henrion <mux@FreeBSD.org> | 2006-03-14 03:51:13 +0000 |
| commit | 7d6ea92e92a7607d000a38aa6c5f5c28ba14b576 (patch) | |
| tree | 80b6fdd284bd04cc067d4a1238cffafd9331f83b /contrib/csup/misc.c | |
| parent | 91be0d8ce36a3d2846486eb436ad4332e805009e (diff) | |
Diffstat (limited to 'contrib/csup/misc.c')
| -rw-r--r-- | contrib/csup/misc.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/contrib/csup/misc.c b/contrib/csup/misc.c index b97a54288036..97a02aba8368 100644 --- a/contrib/csup/misc.c +++ b/contrib/csup/misc.c @@ -34,6 +34,7 @@ #include <err.h> #include <errno.h> #include <fcntl.h> +#include <limits.h> #include <pthread.h> #include <stdarg.h> #include <stdio.h> @@ -64,6 +65,24 @@ static void bt_update(struct backoff_timer *); static void bt_addjitter(struct backoff_timer *); int +asciitoint(const char *s, int *val, int base) +{ + char *end; + long longval; + + errno = 0; + longval = strtol(s, &end, base); + if (errno || *end != '\0') + return (-1); + if (longval > INT_MAX || longval < INT_MIN) { + errno = ERANGE; + return (-1); + } + *val = longval; + return (0); +} + +int lprintf(int level, const char *fmt, ...) { FILE *to; |
