Tranform string values into 64-bit unsigned integers
This commit is contained in:
parent
88c124f4bc
commit
7d9b89e9f8
|
@ -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
|
||||
|
|
11
src/scribe.c
11
src/scribe.c
|
@ -1,6 +1,7 @@
|
|||
#include <gargoyle/codex.h>
|
||||
#include <gargoyle/scribe.h>
|
||||
#include <gargoyle/twine.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue