diff options
author | Jan Engelhardt <jengelh@medozas.de> | 2008-01-20 13:18:54 +0000 |
---|---|---|
committer | Patrick McHardy <kaber@trash.net> | 2008-01-20 13:18:54 +0000 |
commit | cd9e7aa106e80c44bd526af74b616701b0772d05 (patch) | |
tree | 1949ecd290fbb73230dc10b9eb55e8695a71038c /libiptc/linux_stddef.h | |
parent | f82070f9871d281c2802c1624dcf222886b5fb50 (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 <jengelh@computergmbh.de>
Diffstat (limited to 'libiptc/linux_stddef.h')
0 files changed, 0 insertions, 0 deletions