summaryrefslogblamecommitdiffstats
path: root/lstring.h
blob: 1d209673d0ee314528bef689a007a04da6f39165 (plain) (tree)

































                                                                                       
#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