]> git.kaiwu.me - haproxy.git/commit
MINOR: tools: add some of the missing null-terminated integer parsers
authorWilly Tarreau <w@1wt.eu>
Thu, 19 Nov 2026 16:26:44 +0000 (17:26 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 20 Nov 2026 11:36:58 +0000 (12:36 +0100)
commitb923aa9d2df98b20bc0fa610876e4fc6496f1309
treeb0213c34dc4832d6a5b33b8947b4aba64c02be4e
parent8475b372cd35519d6aad4eaeb6312abe8d703a2a
MINOR: tools: add some of the missing null-terminated integer parsers

We have a number of integer parsers depending on what delimits the
integer, but the null-terminated ones were still fairly limited,
especially when range checks were expected. This commit adds the
following parsers:

  int str2irc(const char *str, int *ret);
  int str2uirc(const char *str, uint *ret);
  int str2lrc(const char *str, long *ret);
  int str2ulrc(const char *str, ulong *ret);
  int str2llrc(const char *str, llong *ret);
  int str2ullrc(const char *str, ullong *ret);

The all return an error status like their equivalent length-defined
ones, with the returned value via a pointer. They stop on a null
character and return parsing error when non-digit chars appear in the
string, or when too large a number is being produced for the range.

Note that for now they're in tools.c and defined in intops.h because
other ones were done similarly, but all of these should move to a new
intops.c file.
include/haproxy/intops.h
src/tools.c