blob: ee8904f692d0226f6b26360474b6128456080090 (
plain) (
tree)
|
|
#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;
}
|