summaryrefslogtreecommitdiffstats
path: root/contrib/csup/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/csup/misc.c')
-rw-r--r--contrib/csup/misc.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/contrib/csup/misc.c b/contrib/csup/misc.c
index b97a542..97a02ab 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;
OpenPOWER on IntegriCloud