diff options
Diffstat (limited to 'lstring.h')
-rw-r--r-- | lstring.h | 34 |
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 |