|
@@ -13,7 +13,7 @@ enum parse_opt_type {
|
|
OPTION_BIT,
|
|
OPTION_BIT,
|
|
OPTION_BOOLEAN,
|
|
OPTION_BOOLEAN,
|
|
OPTION_INCR,
|
|
OPTION_INCR,
|
|
- OPTION_SET_INT,
|
|
|
|
|
|
+ OPTION_SET_UINT,
|
|
OPTION_SET_PTR,
|
|
OPTION_SET_PTR,
|
|
/* options with arguments (usually) */
|
|
/* options with arguments (usually) */
|
|
OPTION_STRING,
|
|
OPTION_STRING,
|
|
@@ -79,7 +79,7 @@ typedef int parse_opt_cb(const struct option *, const char *arg, int unset);
|
|
*
|
|
*
|
|
* `defval`::
|
|
* `defval`::
|
|
* default value to fill (*->value) with for PARSE_OPT_OPTARG.
|
|
* default value to fill (*->value) with for PARSE_OPT_OPTARG.
|
|
- * OPTION_{BIT,SET_INT,SET_PTR} store the {mask,integer,pointer} to put in
|
|
|
|
|
|
+ * OPTION_{BIT,SET_UINT,SET_PTR} store the {mask,integer,pointer} to put in
|
|
* the value when met.
|
|
* the value when met.
|
|
* CALLBACKS can use it like they want.
|
|
* CALLBACKS can use it like they want.
|
|
*/
|
|
*/
|
|
@@ -101,16 +101,16 @@ struct option {
|
|
#define OPT_END() { .type = OPTION_END }
|
|
#define OPT_END() { .type = OPTION_END }
|
|
#define OPT_ARGUMENT(l, h) { .type = OPTION_ARGUMENT, .long_name = (l), .help = (h) }
|
|
#define OPT_ARGUMENT(l, h) { .type = OPTION_ARGUMENT, .long_name = (l), .help = (h) }
|
|
#define OPT_GROUP(h) { .type = OPTION_GROUP, .help = (h) }
|
|
#define OPT_GROUP(h) { .type = OPTION_GROUP, .help = (h) }
|
|
-#define OPT_BIT(s, l, v, h, b) { .type = OPTION_BIT, .short_name = (s), .long_name = (l), .value = (v), .help = (h), .defval = (b) }
|
|
|
|
|
|
+#define OPT_BIT(s, l, v, h, b) { .type = OPTION_BIT, .short_name = (s), .long_name = (l), .value = check_vtype(v, int *), .help = (h), .defval = (b) }
|
|
#define OPT_BOOLEAN(s, l, v, h) { .type = OPTION_BOOLEAN, .short_name = (s), .long_name = (l), .value = check_vtype(v, bool *), .help = (h) }
|
|
#define OPT_BOOLEAN(s, l, v, h) { .type = OPTION_BOOLEAN, .short_name = (s), .long_name = (l), .value = check_vtype(v, bool *), .help = (h) }
|
|
-#define OPT_INCR(s, l, v, h) { .type = OPTION_INCR, .short_name = (s), .long_name = (l), .value = (v), .help = (h) }
|
|
|
|
-#define OPT_SET_INT(s, l, v, h, i) { .type = OPTION_SET_INT, .short_name = (s), .long_name = (l), .value = (v), .help = (h), .defval = (i) }
|
|
|
|
|
|
+#define OPT_INCR(s, l, v, h) { .type = OPTION_INCR, .short_name = (s), .long_name = (l), .value = check_vtype(v, int *), .help = (h) }
|
|
|
|
+#define OPT_SET_UINT(s, l, v, h, i) { .type = OPTION_SET_UINT, .short_name = (s), .long_name = (l), .value = check_vtype(v, unsigned int *), .help = (h), .defval = (i) }
|
|
#define OPT_SET_PTR(s, l, v, h, p) { .type = OPTION_SET_PTR, .short_name = (s), .long_name = (l), .value = (v), .help = (h), .defval = (p) }
|
|
#define OPT_SET_PTR(s, l, v, h, p) { .type = OPTION_SET_PTR, .short_name = (s), .long_name = (l), .value = (v), .help = (h), .defval = (p) }
|
|
#define OPT_INTEGER(s, l, v, h) { .type = OPTION_INTEGER, .short_name = (s), .long_name = (l), .value = check_vtype(v, int *), .help = (h) }
|
|
#define OPT_INTEGER(s, l, v, h) { .type = OPTION_INTEGER, .short_name = (s), .long_name = (l), .value = check_vtype(v, int *), .help = (h) }
|
|
#define OPT_UINTEGER(s, l, v, h) { .type = OPTION_UINTEGER, .short_name = (s), .long_name = (l), .value = check_vtype(v, unsigned int *), .help = (h) }
|
|
#define OPT_UINTEGER(s, l, v, h) { .type = OPTION_UINTEGER, .short_name = (s), .long_name = (l), .value = check_vtype(v, unsigned int *), .help = (h) }
|
|
-#define OPT_LONG(s, l, v, h) { .type = OPTION_LONG, .short_name = (s), .long_name = (l), .value = (v), .help = (h) }
|
|
|
|
-#define OPT_U64(s, l, v, h) { .type = OPTION_U64, .short_name = (s), .long_name = (l), .value = (v), .help = (h) }
|
|
|
|
-#define OPT_STRING(s, l, v, a, h) { .type = OPTION_STRING, .short_name = (s), .long_name = (l), .value = (v), (a), .help = (h) }
|
|
|
|
|
|
+#define OPT_LONG(s, l, v, h) { .type = OPTION_LONG, .short_name = (s), .long_name = (l), .value = check_vtype(v, long *), .help = (h) }
|
|
|
|
+#define OPT_U64(s, l, v, h) { .type = OPTION_U64, .short_name = (s), .long_name = (l), .value = check_vtype(v, u64 *), .help = (h) }
|
|
|
|
+#define OPT_STRING(s, l, v, a, h) { .type = OPTION_STRING, .short_name = (s), .long_name = (l), .value = check_vtype(v, const char **), (a), .help = (h) }
|
|
#define OPT_DATE(s, l, v, h) \
|
|
#define OPT_DATE(s, l, v, h) \
|
|
{ .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value = (v), .argh = "time", .help = (h), .callback = parse_opt_approxidate_cb }
|
|
{ .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value = (v), .argh = "time", .help = (h), .callback = parse_opt_approxidate_cb }
|
|
#define OPT_CALLBACK(s, l, v, a, h, f) \
|
|
#define OPT_CALLBACK(s, l, v, a, h, f) \
|