diff --git a/include/gargoyle/codex.h b/include/gargoyle/codex.h index 0d09ba1..aa3edd6 100644 --- a/include/gargoyle/codex.h +++ b/include/gargoyle/codex.h @@ -12,5 +12,6 @@ static const uint8_t GARGOYLE_TYPE_DBLE = 1 << 4; static const uint8_t GARGOYLE_ERR_SUCCESS = 0; static const uint8_t GARGOYLE_ERR_UNKNOWN_OPT = 1; static const uint8_t GARGOYLE_ERR_VALUE_REQUIRED = 2; +static const uint8_t GARGOYLE_ERR_INVALID_UINT = 3; #endif diff --git a/src/scribe.c b/src/scribe.c index 4701faf..b46ee6c 100644 --- a/src/scribe.c +++ b/src/scribe.c @@ -1,6 +1,7 @@ #include #include #include +#include uint8_t gargoyle_from_bool(struct gargoyle_opt *opt, const char *brand) { if(opt->val) { @@ -12,5 +13,15 @@ uint8_t gargoyle_from_bool(struct gargoyle_opt *opt, const char *brand) { } uint8_t gargoyle_from_rope(struct gargoyle_opt *opt, const char *brand) { + if(opt->type & GARGOYLE_TYPE_UINT) { + char *end = NULL; + uint64_t *val = opt->val; + *val = strtoull(brand, &end, 10); + + if(*end) { + return GARGOYLE_ERR_INVALID_UINT; + } + } + return 0; }