basic/parse-util: add helper to parse bounded unsigned values

"parse_range" is already used for stuff like "a-b", so use "bounded" here to
avoid confusion.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2023-09-19 09:35:52 +02:00
parent f31fa08057
commit 3b6cabd806
3 changed files with 43 additions and 1 deletions
+2 -1
View File
@@ -30,11 +30,12 @@ int parse_fd(const char *t);
#define SAFE_ATO_MASK_FLAGS(base) ((base) & ~SAFE_ATO_ALL_FLAGS)
int safe_atou_full(const char *s, unsigned base, unsigned *ret_u);
static inline int safe_atou(const char *s, unsigned *ret_u) {
return safe_atou_full(s, 0, ret_u);
}
int safe_atou_bounded(const char *s, unsigned min, unsigned max, unsigned *ret);
int safe_atoi(const char *s, int *ret_i);
int safe_atolli(const char *s, long long int *ret_i);