"\t --debug [off] Enable debug mode\n" \
"\t --silent [off] Suppress notices and warnings\n"
-struct {
+static struct {
bool help;
bool exit;
bool verbose;
bool silent;
} test_conf;
+static struct conf_ctx *test_ctx;
+
static int aftercheck_debug(struct conf_option *opt, int argc, char **argv,
int idx)
{
}
#define TEST_OPTIONS \
- CONF_OPTION_BOOL('h', "help", aftercheck_help, &test_conf.help, false), \
- CONF_OPTION_BOOL('v', "verbose", NULL, &test_conf.verbose, false), \
- CONF_OPTION_BOOL(0, "debug", aftercheck_debug, &test_conf.debug, false), \
- CONF_OPTION_BOOL(0, "silent", NULL, &test_conf.silent, false)
+ CONF_OPTION_BOOL_FULL('h', "help", aftercheck_help, NULL, NULL, &test_conf.help, false), \
+ CONF_OPTION_BOOL('v', "verbose", &test_conf.verbose, false), \
+ CONF_OPTION_BOOL_FULL(0, "debug", aftercheck_debug, NULL, NULL, &test_conf.debug, false), \
+ CONF_OPTION_BOOL(0, "silent", &test_conf.silent, false)
static void sig_generic(struct ev_eloop *p, struct signalfd_siginfo *info,
void *data)
int ret;
struct ev_eloop *eloop;
- ret = conf_parse_argv(opts, len, argc, argv);
+ ret = conf_ctx_new(&test_ctx, opts, len, &test_conf);
+ if (ret)
+ return ret;
+
+ ret = conf_ctx_parse_argv(test_ctx, argc, argv);
if (ret)
goto err_out;
err_unref:
ev_eloop_unref(eloop);
err_out:
- conf_free(opts, len);
+ conf_ctx_free(test_ctx);
return ret;
}
ev_eloop_unregister_signal_cb(eloop, SIGINT, sig_generic, eloop);
ev_eloop_unregister_signal_cb(eloop, SIGTERM, sig_generic, eloop);
ev_eloop_unref(eloop);
- conf_free(opts, len);
+ conf_ctx_free(test_ctx);
}
struct conf_option options[] = {
TEST_OPTIONS,
- CONF_OPTION_STRING(0, "xkb-layout", NULL, &input_conf.xkb_layout, ""),
- CONF_OPTION_STRING(0, "xkb-variant", NULL, &input_conf.xkb_variant, ""),
- CONF_OPTION_STRING(0, "xkb-options", NULL, &input_conf.xkb_options, ""),
+ CONF_OPTION_STRING(0, "xkb-layout", &input_conf.xkb_layout, ""),
+ CONF_OPTION_STRING(0, "xkb-variant", &input_conf.xkb_variant, ""),
+ CONF_OPTION_STRING(0, "xkb-options", &input_conf.xkb_options, ""),
};
int main(int argc, char **argv)
struct conf_option options[] = {
TEST_OPTIONS,
- CONF_OPTION_BOOL(0, "fbdev", NULL, &output_conf.fbdev, false),
- CONF_OPTION_BOOL(0, "test", NULL, &output_conf.test, false),
- CONF_OPTION_STRING(0, "dev", NULL, &output_conf.dev, NULL),
+ CONF_OPTION_BOOL(0, "fbdev", &output_conf.fbdev, false),
+ CONF_OPTION_BOOL(0, "test", &output_conf.test, false),
+ CONF_OPTION_STRING(0, "dev", &output_conf.dev, NULL),
};
int main(int argc, char **argv)