From a64417804f4c2b0425e167851d10854cf1f23e99 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sat, 1 Jul 2023 12:41:56 +0200 Subject: Consolidate some of the stray integer parsers There are several ad-hoc int/uint parsers scattered around the code, add a single helper function for that task and replace the multiple instances. A simple white-box test case is added for the utility function. Signed-off-by: David Oberhollenzer --- include/util/parse.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/util/parse.h b/include/util/parse.h index e132d6b..20b4cb7 100644 --- a/include/util/parse.h +++ b/include/util/parse.h @@ -66,6 +66,12 @@ SQFS_INTERNAL void trim(char *buffer); SQFS_INTERNAL int istream_get_line(sqfs_istream_t *strm, char **out, size_t *line_num, int flags); +SQFS_INTERNAL int parse_int(const char *in, size_t len, size_t *diff, + sqfs_s64 vmin, sqfs_s64 vmax, sqfs_s64 *out); + +SQFS_INTERNAL int parse_uint(const char *in, size_t len, size_t *diff, + sqfs_u64 vmin, sqfs_u64 vmax, sqfs_u64 *out); + /** * @brief Split a line of special character separated tokens * -- cgit v1.2.3