#include #include #include #include uint8_t gargoyle_from_bool(struct gargoyle_opt *opt, const char *brand) { if(opt->val) { uint8_t *val = opt->val; *val = !gargoyle_cmp(brand, "no-", 3, GARGOYLE_CMP_ICASE); } return 0; } 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; } } else if(opt->type & GARGOYLE_TYPE_DBLE) { char *end = NULL; double *val = opt->val; *val = strtod(brand, &end); if(*end) { return GARGOYLE_ERR_INVALID_DBLE; } } else if(opt->type & GARGOYLE_TYPE_ROPE) { char *val = opt->val; char *end = gargoyle_cpy(val, brand, opt->val_sz - 1); *end = '\0'; } else { return GARGOYLE_ERR_UNKNOWN_TYPE; } return 0; }