From 9693a8bf05e5ef61a7a74ed14a985e7e16a037d8 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Thu, 24 Feb 2005 16:37:54 +0000 Subject: fix --- opts.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'opts.c') diff --git a/opts.c b/opts.c index 4027d18..373e5b6 100644 --- a/opts.c +++ b/opts.c @@ -7,6 +7,7 @@ */ #include "opts.h" +#include #include #include #include @@ -102,3 +103,20 @@ void process_options(int *argcp, char *argv[], struct opt opts[], } *argcp = newargctr; } + +int opt_get_unsigned(const struct opt *o, unsigned *valp) +{ + char *end; + unsigned val; + if (!o->value || !o->value[0]) { + fprintf(stderr, "Missing value for '%s' option\n", o->optname); + return -1; + } + val = strtoul(o->value, &end, 0); + if (end[0]) { + fprintf(stderr, "Invalid value for '%s' option\n", o->optname); + return -1; + } + *valp = val; + return 0; +} -- cgit v1.2.3