summaryrefslogtreecommitdiffstats
path: root/lstring.c
diff options
context:
space:
mode:
authorSimon Rettberg2018-11-09 15:35:46 +0100
committerSimon Rettberg2018-11-09 15:35:46 +0100
commitba817d465caa48b5b814853d8f16602da2d1a8a9 (patch)
treef082b752a8e2aed477aa57ff00f7244238769b41 /lstring.c
parentRemove memberOf filtering; not required for proper operation (diff)
downloadldadp-ba817d465caa48b5b814853d8f16602da2d1a8a9.tar.gz
ldadp-ba817d465caa48b5b814853d8f16602da2d1a8a9.tar.xz
ldadp-ba817d465caa48b5b814853d8f16602da2d1a8a9.zip
Move string functions to lstring.[hc]
Diffstat (limited to 'lstring.c')
-rw-r--r--lstring.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/lstring.c b/lstring.c
new file mode 100644
index 0000000..ee8904f
--- /dev/null
+++ b/lstring.c
@@ -0,0 +1,30 @@
+#include "lstring.h"
+
+BOOL isInt(const struct string *value, int start)
+{
+ size_t i;
+ for (i = start; i < value->l; ++i) {
+ if (value->s[i] < '0' || value->s[i] > '9') return FALSE;
+ }
+ return TRUE;
+}
+
+uint32_t parseUInt32(const struct string * const s)
+{
+ if (s == NULL || s->l > 10) {
+ return 0;
+ }
+ uint32_t ret = 0, last = 0;
+ for (size_t i = 0; i < s->l; ++i) {
+ if (s->s[i] < '0' || s->s[i] > '9') {
+ return 0;
+ }
+ ret = ret * 10 + (s->s[i] - '0');
+ if (ret < last) {
+ return 0;
+ }
+ last = ret;
+ }
+ return ret;
+}
+