diff options
Diffstat (limited to 'wsutil/clopts_common.c')
-rw-r--r-- | wsutil/clopts_common.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/wsutil/clopts_common.c b/wsutil/clopts_common.c index 1967014c82..78763328d5 100644 --- a/wsutil/clopts_common.c +++ b/wsutil/clopts_common.c @@ -56,7 +56,6 @@ get_natural_int(const char *string, const char *name) return (int)number; } - int get_positive_int(const char *string, const char *name) { @@ -72,6 +71,39 @@ get_positive_int(const char *string, const char *name) return number; } +guint32 +get_guint32(const char *string, const char *name) +{ + const char *end; + guint32 number; + + if (!ws_strtou32(string, &end, &number)) { + if (errno == EINVAL || *end != '\0') { + cmdarg_err("The specified %s \"%s\" isn't a decimal number", name, string); + exit(1); + } + cmdarg_err("The specified %s \"%s\" is too large (greater than %d)", + name, string, number); + exit(1); + } + return number; +} + +guint32 +get_nonzero_guint32(const char *string, const char *name) +{ + guint32 number; + + number = get_guint32(string, name); + + if (number == 0) { + cmdarg_err("The specified %s is zero", name); + exit(1); + } + + return number; +} + /* * Editor modelines - http://www.wireshark.org/tools/modelines.html * |