diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-07-01 12:41:56 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-07-03 00:57:06 +0200 |
commit | a64417804f4c2b0425e167851d10854cf1f23e99 (patch) | |
tree | 663cbafb8f30df0d82a289c69a4ace43656bd154 /include/util | |
parent | a201669daff7e64255148404a27bed6c0df1eaa4 (diff) |
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 <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'include/util')
-rw-r--r-- | include/util/parse.h | 6 |
1 files changed, 6 insertions, 0 deletions
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 * |