path: root/include/xtables.h
diff options
author/C=EU/ST=EU/CN=Patrick McHardy/ </C=EU/ST=EU/CN=Patrick McHardy/>2008-01-20 13:18:54 +0000
committer/C=EU/ST=EU/CN=Patrick McHardy/ </C=EU/ST=EU/CN=Patrick McHardy/>2008-01-20 13:18:54 +0000
commitfd60e9c668e55cc6c4a6f29130b96b7b4e33d6f3 (patch)
tree1949ecd290fbb73230dc10b9eb55e8695a71038c /include/xtables.h
parent0d0ef5c79805e6a7dc95f82c1cb67be09422b9ed (diff)
Introduce strtonum(), which works like string_to_number(), but passes
back the 'end' pointer. It is useful where you want to do boundary checking yet work with strings that are not entirely slurped by strtoul(), e.g.: s = "1/2"; /* one half */ if (!strtonum(s, &end, &value, 0, 5)) error("Zero-length string, or value out of bounds"); if (*end != '/') error("Malformed string"); info->param1 = value; if (!strtonum(end + 1, &end, &value, 2, 4)) error(".."); if (*end != '\0') error("Malformed string"); info->param2 = value; Signed-off-by: Jan Engelhardt <>
Diffstat (limited to 'include/xtables.h')
1 files changed, 5 insertions, 0 deletions
diff --git a/include/xtables.h b/include/xtables.h
index 577b3c6..728b1aa 100644
--- a/include/xtables.h
+++ b/include/xtables.h
@@ -5,6 +5,7 @@
#include <linux/types.h>
#include <linux/netfilter/x_tables.h>
#include <libiptc/libxtc.h>
+#include <stdbool.h>
#ifndef XT_LIB_DIR
#define XT_LIB_DIR "/usr/local/lib/iptables"
@@ -206,6 +207,10 @@ extern int string_to_number(const char *s,
unsigned int min,
unsigned int max,
unsigned int *ret);
+extern bool strtonuml(const char *, char **, unsigned long *,
+ unsigned long, unsigned long);
+extern bool strtonum(const char *, char **, unsigned int *,
+ unsigned int, unsigned int);
extern int service_to_port(const char *name, const char *proto);
extern u_int16_t parse_port(const char *port, const char *proto);
extern void