summaryrefslogtreecommitdiff
path: root/src/include/string.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/string.h')
-rw-r--r--src/include/string.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/include/string.h b/src/include/string.h
index 4a2f5e9ee6..c56a760a04 100644
--- a/src/include/string.h
+++ b/src/include/string.h
@@ -178,4 +178,19 @@ static inline int tolower(int c)
c -= 'A'-'a';
return c;
}
+
+/*
+ * Parses an unsigned integer and moves the input pointer forward to the first
+ * character that's not a valid digit. s and *s must not be NULL. Result
+ * undefined if it overruns the return type size.
+ */
+static inline unsigned int skip_atoi(char **s)
+{
+ unsigned int i = 0;
+
+ while (isdigit(**s))
+ i = i*10 + *((*s)++) - '0';
+ return i;
+}
+
#endif /* STRING_H */