summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/libbb.h6
-rw-r--r--include/xatonum.h12
2 files changed, 12 insertions, 6 deletions
diff --git a/include/libbb.h b/include/libbb.h
index 152fb7e..5cba279 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -317,17 +317,11 @@ struct suffix_mult {
};
#include "xatonum.h"
/* Specialized: */
-unsigned xatou_range(const char *numstr, unsigned lower, unsigned upper);
-unsigned xatou_sfx(const char *numstr, const struct suffix_mult *suffixes);
-unsigned xatou(const char *numstr);
-int xatoi_range(const char *numstr, int lower, int upper);
-int xatoi(const char *numstr);
/* Using xatoi() instead of naive atoi() is not always convenient -
* in many places people want *non-negative* values, but store them
* in signed int. Therefore we need this one:
* dies if input is not in [0, INT_MAX] range. Also will reject '-0' etc */
int xatoi_u(const char *numstr);
-uint32_t xatou32(const char *numstr);
/* Useful for reading port numbers */
uint16_t xatou16(const char *numstr);
diff --git a/include/xatonum.h b/include/xatonum.h
index cdb5e73..46e49b0 100644
--- a/include/xatonum.h
+++ b/include/xatonum.h
@@ -92,3 +92,15 @@ DEFINE_EQUIV_STR_CONV(int, i, l, u, ul)
#else
DECLARE_STR_CONV(int, i, u)
#endif
+
+/* Specialized */
+
+int BUG_xatou32_unimplemented(void);
+extern inline uint32_t xatou32(const char *numstr)
+{
+ if (UINT_MAX == 0xffffffff)
+ return xatou(numstr);
+ if (ULONG_MAX == 0xffffffff)
+ return xatoul(numstr);
+ return BUG_xatou32_unimplemented();
+}