Add support for signed integers
This commit is contained in:
parent
60b54e37c0
commit
f97be5af3b
2 changed files with 14 additions and 4 deletions
|
@ -7,8 +7,9 @@ typedef uint8_t gargoyle_opt_type;
|
||||||
|
|
||||||
static const gargoyle_opt_type GARGOYLE_TYPE_BOOL = 1 << 0;
|
static const gargoyle_opt_type GARGOYLE_TYPE_BOOL = 1 << 0;
|
||||||
static const gargoyle_opt_type GARGOYLE_TYPE_UINT = 1 << 1;
|
static const gargoyle_opt_type GARGOYLE_TYPE_UINT = 1 << 1;
|
||||||
static const gargoyle_opt_type GARGOYLE_TYPE_DBLE = 1 << 2;
|
static const gargoyle_opt_type GARGOYLE_TYPE_SINT = 1 << 2;
|
||||||
static const gargoyle_opt_type GARGOYLE_TYPE_ROPE = 1 << 3;
|
static const gargoyle_opt_type GARGOYLE_TYPE_DBLE = 1 << 3;
|
||||||
|
static const gargoyle_opt_type GARGOYLE_TYPE_ROPE = 1 << 4;
|
||||||
|
|
||||||
typedef uint8_t gargoyle_err_type;
|
typedef uint8_t gargoyle_err_type;
|
||||||
|
|
||||||
|
@ -16,8 +17,9 @@ static const gargoyle_err_type GARGOYLE_ERR_SUCCESS = 1 << 0;
|
||||||
static const gargoyle_err_type GARGOYLE_ERR_UNKNOWN_OPT = 1 << 1;
|
static const gargoyle_err_type GARGOYLE_ERR_UNKNOWN_OPT = 1 << 1;
|
||||||
static const gargoyle_err_type GARGOYLE_ERR_VALUE_REQUIRED = 1 << 2;
|
static const gargoyle_err_type GARGOYLE_ERR_VALUE_REQUIRED = 1 << 2;
|
||||||
static const gargoyle_err_type GARGOYLE_ERR_INVALID_UINT = 1 << 3;
|
static const gargoyle_err_type GARGOYLE_ERR_INVALID_UINT = 1 << 3;
|
||||||
static const gargoyle_err_type GARGOYLE_ERR_INVALID_DBLE = 1 << 4;
|
static const gargoyle_err_type GARGOYLE_ERR_INVALID_SINT = 1 << 4;
|
||||||
static const gargoyle_err_type GARGOYLE_ERR_UNKNOWN_TYPE = 1 << 5;
|
static const gargoyle_err_type GARGOYLE_ERR_INVALID_DBLE = 1 << 5;
|
||||||
|
static const gargoyle_err_type GARGOYLE_ERR_UNKNOWN_TYPE = 1 << 6;
|
||||||
|
|
||||||
typedef uint8_t gargoyle_flag_type;
|
typedef uint8_t gargoyle_flag_type;
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,14 @@ uint8_t gargoyle_from_rope(struct gargoyle_opt *opt, const char *brand_val, garg
|
||||||
if(*end) {
|
if(*end) {
|
||||||
return GARGOYLE_ERR_INVALID_UINT;
|
return GARGOYLE_ERR_INVALID_UINT;
|
||||||
}
|
}
|
||||||
|
} else if(opt->type & GARGOYLE_TYPE_SINT) {
|
||||||
|
char *end = NULL;
|
||||||
|
int64_t *val = opt->val;
|
||||||
|
*val = strtoll(brand_val, &end, 10);
|
||||||
|
|
||||||
|
if(*end) {
|
||||||
|
return GARGOYLE_ERR_INVALID_SINT;
|
||||||
|
}
|
||||||
} else if(opt->type & GARGOYLE_TYPE_DBLE) {
|
} else if(opt->type & GARGOYLE_TYPE_DBLE) {
|
||||||
char *end = NULL;
|
char *end = NULL;
|
||||||
double *val = opt->val;
|
double *val = opt->val;
|
||||||
|
|
Loading…
Reference in a new issue