summaryrefslogtreecommitdiffstats
path: root/lstring.h
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.h
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.h')
-rw-r--r--lstring.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/lstring.h b/lstring.h
new file mode 100644
index 0000000..1d20967
--- /dev/null
+++ b/lstring.h
@@ -0,0 +1,34 @@
+#ifndef _LSTRING_H_
+#define _LSTRING_H_
+
+#include "asn1.h"
+#include "types.h"
+
+#include <ctype.h>
+#include <string.h>
+
+BOOL isInt(const struct string * const value, int start);
+
+uint32_t parseUInt32(const struct string * const s);
+
+static inline int equals(const struct string *a, const struct string *b)
+{
+ if (a->l != b->l) return 0;
+ if (a->s == b->s) return 1;
+ return strncmp(a->s, b->s, a->l) == 0;
+}
+
+/**
+ * b MUST be in lowercase already.
+ */
+static inline int iequals(const struct string * const a, const struct string * const b)
+{
+ if (a->l != b->l) return 0;
+ if (a->s == b->s) return 1;
+ for (size_t i = 0; i < a->l; ++i) {
+ if (tolower(a->s[i]) != b->s[i]) return 0;
+ }
+ return 1;
+}
+
+#endif