aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/str.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/str.c b/lib/str.c
index 9b5b201..5fbb8ad 100644
--- a/lib/str.c
+++ b/lib/str.c
@@ -817,3 +817,30 @@ int strcmp_array(const char **a, const char **b) {
}
return result;
}
+
+/**
+ * Determine whether a string is comprised of digits
+ * @param s
+ * @return 0=no, 1=yes
+ */
+int isdigit_s(char *s) {
+ for (size_t i = 0; s[i] != '\0'; i++) {
+ if (isdigit(s[i]) == 0) {
+ return 0; // non-digit found, fail
+ }
+ }
+ return 1; // all digits, succeed
+}
+
+/**
+ * Convert input string to lowercase
+ * @param s
+ * @return pointer to input string
+ */
+char *tolower_s(char *s) {
+ for (size_t i = 0; s[i] != '\0'; i++) {
+ s[i] = (char)tolower(s[i]);
+ }
+ return s;
+}
+