conf: simplify helper macros
Instead of using "NULL, NULL, NULL, " in every macro, we now provide a *_FULL variant which allows setting these. All other macros simply set these to NULL by default. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
parent
8923fe2123
commit
d4529d735a
90
src/conf.h
90
src/conf.h
@ -168,65 +168,35 @@ struct conf_option {
|
||||
|
||||
#define CONF_OPTION(_flags, _short, _long, _type, _aftercheck, _copy, _file, _mem, _def) \
|
||||
{ _flags, _short, "no-" _long, _type, _aftercheck, _copy, _file, _mem, _def }
|
||||
#define CONF_OPTION_BOOL(_short, _long, _aftercheck, _copy, _mem, _def) \
|
||||
CONF_OPTION(0, \
|
||||
_short, \
|
||||
_long, \
|
||||
&conf_bool, \
|
||||
_aftercheck, \
|
||||
_copy, \
|
||||
NULL, \
|
||||
_mem, \
|
||||
_def)
|
||||
#define CONF_OPTION_INT(_short, _long, _aftercheck, _copy, _mem, _def) \
|
||||
CONF_OPTION(0, \
|
||||
_short, \
|
||||
_long, \
|
||||
&conf_int, \
|
||||
_aftercheck, \
|
||||
_copy, \
|
||||
NULL, \
|
||||
_mem, \
|
||||
(void*)(unsigned long)_def)
|
||||
#define CONF_OPTION_UINT(_short, _long, _aftercheck, _copy, _mem, _def) \
|
||||
CONF_OPTION(0, \
|
||||
_short, \
|
||||
_long, \
|
||||
&conf_uint, \
|
||||
_aftercheck, \
|
||||
_copy, \
|
||||
NULL, \
|
||||
_mem, \
|
||||
(void*)(unsigned long)_def)
|
||||
#define CONF_OPTION_STRING(_short, _long, _aftercheck, _copy, _mem, _def) \
|
||||
CONF_OPTION(0, \
|
||||
_short, \
|
||||
_long, \
|
||||
&conf_string, \
|
||||
_aftercheck, \
|
||||
_copy, \
|
||||
NULL, \
|
||||
_mem, \
|
||||
_def)
|
||||
#define CONF_OPTION_STRING_LIST(_short, _long, _aftercheck, _copy, _mem, _def) \
|
||||
CONF_OPTION(0, \
|
||||
_short, \
|
||||
_long, \
|
||||
&conf_string_list, \
|
||||
_aftercheck, \
|
||||
_copy, \
|
||||
NULL, \
|
||||
_mem, \
|
||||
_def)
|
||||
#define CONF_OPTION_GRAB(_short, _long, _aftercheck, _copy, _mem, _def) \
|
||||
CONF_OPTION(0, \
|
||||
_short, \
|
||||
_long, \
|
||||
&conf_grab, \
|
||||
_aftercheck, \
|
||||
_copy, \
|
||||
NULL, \
|
||||
_mem, \
|
||||
_def)
|
||||
|
||||
#define CONF_OPTION_BOOL_FULL(_short, _long, _aftercheck, _copy, _file, _mem, _def) \
|
||||
CONF_OPTION(0, _short, _long, &conf_bool, _aftercheck, _copy, _file, _mem, _def)
|
||||
#define CONF_OPTION_BOOL(_short, _long, _mem, _def) \
|
||||
CONF_OPTION_BOOL_FULL(_short, _long, NULL, NULL, NULL, _mem, _def)
|
||||
|
||||
#define CONF_OPTION_INT_FULL(_short, _long, _aftercheck, _copy, _file, _mem, _def) \
|
||||
CONF_OPTION(0, _short, _long, &conf_int, _aftercheck, _copy, _file, _mem, (void*)(long)_def)
|
||||
#define CONF_OPTION_INT(_short, _long, _mem, _def) \
|
||||
CONF_OPTION_INT_FULL(_short, _long, NULL, NULL, NULL, _mem, _def)
|
||||
|
||||
#define CONF_OPTION_UINT_FULL(_short, _long, _aftercheck, _copy, _file, _mem, _def) \
|
||||
CONF_OPTION(0, _short, _long, &conf_uint, _aftercheck, _copy, _file, _mem, (void*)(unsigned long)_def)
|
||||
#define CONF_OPTION_UINT(_short, _long, _mem, _def) \
|
||||
CONF_OPTION_UINT_FULL(_short, _long, NULL, NULL, NULL, _mem, _def)
|
||||
|
||||
#define CONF_OPTION_STRING_FULL(_short, _long, _aftercheck, _copy, _file, _mem, _def) \
|
||||
CONF_OPTION(0, _short, _long, &conf_string, _aftercheck, _copy, _file, _mem, _def)
|
||||
#define CONF_OPTION_STRING(_short, _long, _mem, _def) \
|
||||
CONF_OPTION_STRING_FULL(_short, _long, NULL, NULL, NULL, _mem, _def)
|
||||
|
||||
#define CONF_OPTION_STRING_LIST_FULL(_short, _long, _aftercheck, _copy, _file, _mem, _def) \
|
||||
CONF_OPTION(0, _short, _long, &conf_string_list, _aftercheck, _copy, _file, _mem, _def)
|
||||
#define CONF_OPTION_STRING_LIST(_short, _long, _mem, _def) \
|
||||
CONF_OPTION_STRING_LIST_FULL(_short, _long, NULL, NULL, NULL, _mem, _def)
|
||||
|
||||
#define CONF_OPTION_GRAB_FULL(_short, _long, _aftercheck, _copy, _file, _mem, _def) \
|
||||
CONF_OPTION(0, _short, _long, &conf_grab, _aftercheck, _copy, _file, _mem, _def)
|
||||
#define CONF_OPTION_GRAB(_short, _long, _mem, _def) \
|
||||
CONF_OPTION_GRAB_FULL(_short, _long, NULL, NULL, NULL, _mem, _def)
|
||||
|
||||
#endif /* CONFIG_CONFIG_H */
|
||||
|
@ -353,54 +353,54 @@ int kmscon_conf_new(struct conf_ctx **out)
|
||||
|
||||
struct conf_option options[] = {
|
||||
/* Global Options */
|
||||
CONF_OPTION_BOOL('h', "help", aftercheck_help, NULL, &conf->help, false),
|
||||
CONF_OPTION_BOOL('v', "verbose", NULL, NULL, &conf->verbose, false),
|
||||
CONF_OPTION_BOOL(0, "debug", aftercheck_debug, NULL, &conf->debug, false),
|
||||
CONF_OPTION_BOOL(0, "silent", NULL, NULL, &conf->silent, false),
|
||||
CONF_OPTION_BOOL_FULL('h', "help", aftercheck_help, NULL, NULL, &conf->help, false),
|
||||
CONF_OPTION_BOOL('v', "verbose", &conf->verbose, false),
|
||||
CONF_OPTION_BOOL_FULL(0, "debug", aftercheck_debug, NULL, NULL, &conf->debug, false),
|
||||
CONF_OPTION_BOOL(0, "silent", &conf->silent, false),
|
||||
|
||||
/* Seat Options */
|
||||
CONF_OPTION(0, 0, "vt", &conf_vt, NULL, NULL, NULL, &conf->vt, NULL),
|
||||
CONF_OPTION_BOOL('s', "switchvt", NULL, NULL, &conf->switchvt, false),
|
||||
CONF_OPTION_STRING_LIST(0, "seats", aftercheck_seats, copy_seats, &conf->seats, def_seats),
|
||||
CONF_OPTION_BOOL('s', "switchvt", &conf->switchvt, false),
|
||||
CONF_OPTION_STRING_LIST_FULL(0, "seats", aftercheck_seats, copy_seats, NULL, &conf->seats, def_seats),
|
||||
|
||||
/* Session Options */
|
||||
CONF_OPTION_UINT(0, "session-max", NULL, NULL, &conf->session_max, 50),
|
||||
CONF_OPTION_UINT(0, "session-max", &conf->session_max, 50),
|
||||
|
||||
/* Terminal Options */
|
||||
CONF_OPTION_BOOL('l', "login", aftercheck_login, copy_login, &conf->login, false),
|
||||
CONF_OPTION_STRING('t', "term", NULL, NULL, &conf->term, "xterm-256color"),
|
||||
CONF_OPTION_STRING(0, "palette", NULL, NULL, &conf->palette, NULL),
|
||||
CONF_OPTION_UINT(0, "sb-size", NULL, NULL, &conf->sb_size, 1000),
|
||||
CONF_OPTION_BOOL_FULL('l', "login", aftercheck_login, copy_login, NULL, &conf->login, false),
|
||||
CONF_OPTION_STRING('t', "term", &conf->term, "xterm-256color"),
|
||||
CONF_OPTION_STRING(0, "palette", &conf->palette, NULL),
|
||||
CONF_OPTION_UINT(0, "sb-size", &conf->sb_size, 1000),
|
||||
|
||||
/* Input Options */
|
||||
CONF_OPTION_STRING(0, "xkb-layout", NULL, NULL, &conf->xkb_layout, "us"),
|
||||
CONF_OPTION_STRING(0, "xkb-variant", NULL, NULL, &conf->xkb_variant, ""),
|
||||
CONF_OPTION_STRING(0, "xkb-options", NULL, NULL, &conf->xkb_options, ""),
|
||||
CONF_OPTION_UINT(0, "xkb-repeat-delay", NULL, NULL, &conf->xkb_repeat_delay, 250),
|
||||
CONF_OPTION_UINT(0, "xkb-repeat-rate", NULL, NULL, &conf->xkb_repeat_rate, 50),
|
||||
CONF_OPTION_STRING(0, "xkb-layout", &conf->xkb_layout, "us"),
|
||||
CONF_OPTION_STRING(0, "xkb-variant", &conf->xkb_variant, ""),
|
||||
CONF_OPTION_STRING(0, "xkb-options", &conf->xkb_options, ""),
|
||||
CONF_OPTION_UINT(0, "xkb-repeat-delay", &conf->xkb_repeat_delay, 250),
|
||||
CONF_OPTION_UINT(0, "xkb-repeat-rate", &conf->xkb_repeat_rate, 50),
|
||||
|
||||
/* Grabs / Keyboard-Shortcuts */
|
||||
CONF_OPTION_GRAB(0, "grab-scroll-up", NULL, NULL, &conf->grab_scroll_up, &def_grab_scroll_up),
|
||||
CONF_OPTION_GRAB(0, "grab-scroll-down", NULL, NULL, &conf->grab_scroll_down, &def_grab_scroll_down),
|
||||
CONF_OPTION_GRAB(0, "grab-page-up", NULL, NULL, &conf->grab_page_up, &def_grab_page_up),
|
||||
CONF_OPTION_GRAB(0, "grab-page-down", NULL, NULL, &conf->grab_page_down, &def_grab_page_down),
|
||||
CONF_OPTION_GRAB(0, "grab-session-next", NULL, NULL, &conf->grab_session_next, &def_grab_session_next),
|
||||
CONF_OPTION_GRAB(0, "grab-session-prev", NULL, NULL, &conf->grab_session_prev, &def_grab_session_prev),
|
||||
CONF_OPTION_GRAB(0, "grab-session-close", NULL, NULL, &conf->grab_session_close, &def_grab_session_close),
|
||||
CONF_OPTION_GRAB(0, "grab-terminal-new", NULL, NULL, &conf->grab_terminal_new, &def_grab_terminal_new),
|
||||
CONF_OPTION_GRAB(0, "grab-scroll-up", &conf->grab_scroll_up, &def_grab_scroll_up),
|
||||
CONF_OPTION_GRAB(0, "grab-scroll-down", &conf->grab_scroll_down, &def_grab_scroll_down),
|
||||
CONF_OPTION_GRAB(0, "grab-page-up", &conf->grab_page_up, &def_grab_page_up),
|
||||
CONF_OPTION_GRAB(0, "grab-page-down", &conf->grab_page_down, &def_grab_page_down),
|
||||
CONF_OPTION_GRAB(0, "grab-session-next", &conf->grab_session_next, &def_grab_session_next),
|
||||
CONF_OPTION_GRAB(0, "grab-session-prev", &conf->grab_session_prev, &def_grab_session_prev),
|
||||
CONF_OPTION_GRAB(0, "grab-session-close", &conf->grab_session_close, &def_grab_session_close),
|
||||
CONF_OPTION_GRAB(0, "grab-terminal-new", &conf->grab_terminal_new, &def_grab_terminal_new),
|
||||
|
||||
/* Video Options */
|
||||
CONF_OPTION_BOOL(0, "fbdev", NULL, NULL, &conf->fbdev, false),
|
||||
CONF_OPTION_BOOL(0, "dumb", NULL, NULL, &conf->dumb, false),
|
||||
CONF_OPTION_UINT(0, "fps", NULL, NULL, &conf->fps, 50),
|
||||
CONF_OPTION_STRING(0, "render-engine", NULL, NULL, &conf->render_engine, NULL),
|
||||
CONF_OPTION_BOOL(0, "render-timing", NULL, NULL, &conf->render_timing, false),
|
||||
CONF_OPTION_BOOL(0, "fbdev", &conf->fbdev, false),
|
||||
CONF_OPTION_BOOL(0, "dumb", &conf->dumb, false),
|
||||
CONF_OPTION_UINT(0, "fps", &conf->fps, 50),
|
||||
CONF_OPTION_STRING(0, "render-engine", &conf->render_engine, NULL),
|
||||
CONF_OPTION_BOOL(0, "render-timing", &conf->render_timing, false),
|
||||
|
||||
/* Font Options */
|
||||
CONF_OPTION_STRING(0, "font-engine", NULL, NULL, &conf->font_engine, "pango"),
|
||||
CONF_OPTION_UINT(0, "font-size", NULL, NULL, &conf->font_size, 12),
|
||||
CONF_OPTION_STRING(0, "font-name", NULL, NULL, &conf->font_name, "monospace"),
|
||||
CONF_OPTION_UINT(0, "font-dpi", NULL, NULL, &conf->font_ppi, 96),
|
||||
CONF_OPTION_STRING(0, "font-engine", &conf->font_engine, "pango"),
|
||||
CONF_OPTION_UINT(0, "font-size", &conf->font_size, 12),
|
||||
CONF_OPTION_STRING(0, "font-name", &conf->font_name, "monospace"),
|
||||
CONF_OPTION_UINT(0, "font-dpi", &conf->font_ppi, 96),
|
||||
};
|
||||
|
||||
ret = conf_ctx_new(&ctx, options, sizeof(options) / sizeof(*options),
|
||||
|
@ -376,33 +376,33 @@ static struct conf_grab def_grab_paste =
|
||||
CONF_SINGLE_GRAB(SHL_LOGO_MASK, XKB_KEY_v);
|
||||
|
||||
struct conf_option options[] = {
|
||||
CONF_OPTION_BOOL('h', "help", aftercheck_help, NULL, &wlt_conf.help, false),
|
||||
CONF_OPTION_BOOL('v', "verbose", NULL, NULL, &wlt_conf.verbose, false),
|
||||
CONF_OPTION_BOOL(0, "debug", aftercheck_debug, NULL, &wlt_conf.debug, false),
|
||||
CONF_OPTION_BOOL(0, "silent", NULL, NULL, &wlt_conf.silent, false),
|
||||
CONF_OPTION_BOOL_FULL('h', "help", aftercheck_help, NULL, NULL, &wlt_conf.help, false),
|
||||
CONF_OPTION_BOOL('v', "verbose", &wlt_conf.verbose, false),
|
||||
CONF_OPTION_BOOL_FULL(0, "debug", aftercheck_debug, NULL, NULL, &wlt_conf.debug, false),
|
||||
CONF_OPTION_BOOL(0, "silent", &wlt_conf.silent, false),
|
||||
|
||||
CONF_OPTION_BOOL('l', "login", aftercheck_login, copy_login, &wlt_conf.login, false),
|
||||
CONF_OPTION_STRING('t', "term", NULL, NULL, &wlt_conf.term, "xterm-256color"),
|
||||
CONF_OPTION_STRING(0, "palette", NULL, NULL, &wlt_conf.palette, NULL),
|
||||
CONF_OPTION_UINT(0, "sb-size", NULL, NULL, &wlt_conf.sb_size, 1000),
|
||||
CONF_OPTION_BOOL_FULL('l', "login", aftercheck_login, copy_login, NULL, &wlt_conf.login, false),
|
||||
CONF_OPTION_STRING('t', "term", &wlt_conf.term, "xterm-256color"),
|
||||
CONF_OPTION_STRING(0, "palette", &wlt_conf.palette, NULL),
|
||||
CONF_OPTION_UINT(0, "sb-size", &wlt_conf.sb_size, 1000),
|
||||
|
||||
CONF_OPTION_GRAB(0, "grab-scroll-up", NULL, NULL, &wlt_conf.grab_scroll_up, &def_grab_scroll_up),
|
||||
CONF_OPTION_GRAB(0, "grab-scroll-down", NULL, NULL, &wlt_conf.grab_scroll_down, &def_grab_scroll_down),
|
||||
CONF_OPTION_GRAB(0, "grab-page-up", NULL, NULL, &wlt_conf.grab_page_up, &def_grab_page_up),
|
||||
CONF_OPTION_GRAB(0, "grab-page-down", NULL, NULL, &wlt_conf.grab_page_down, &def_grab_page_down),
|
||||
CONF_OPTION_GRAB(0, "grab-fullscreen", NULL, NULL, &wlt_conf.grab_fullscreen, &def_grab_fullscreen),
|
||||
CONF_OPTION_GRAB(0, "grab-zoom-in", NULL, NULL, &wlt_conf.grab_zoom_in, &def_grab_zoom_in),
|
||||
CONF_OPTION_GRAB(0, "grab-zoom-out", NULL, NULL, &wlt_conf.grab_zoom_out, &def_grab_zoom_out),
|
||||
CONF_OPTION_GRAB(0, "grab-copy", NULL, NULL, &wlt_conf.grab_copy, &def_grab_copy),
|
||||
CONF_OPTION_GRAB(0, "grab-paste", NULL, NULL, &wlt_conf.grab_paste, &def_grab_paste),
|
||||
CONF_OPTION_GRAB(0, "grab-scroll-up", &wlt_conf.grab_scroll_up, &def_grab_scroll_up),
|
||||
CONF_OPTION_GRAB(0, "grab-scroll-down", &wlt_conf.grab_scroll_down, &def_grab_scroll_down),
|
||||
CONF_OPTION_GRAB(0, "grab-page-up", &wlt_conf.grab_page_up, &def_grab_page_up),
|
||||
CONF_OPTION_GRAB(0, "grab-page-down", &wlt_conf.grab_page_down, &def_grab_page_down),
|
||||
CONF_OPTION_GRAB(0, "grab-fullscreen", &wlt_conf.grab_fullscreen, &def_grab_fullscreen),
|
||||
CONF_OPTION_GRAB(0, "grab-zoom-in", &wlt_conf.grab_zoom_in, &def_grab_zoom_in),
|
||||
CONF_OPTION_GRAB(0, "grab-zoom-out", &wlt_conf.grab_zoom_out, &def_grab_zoom_out),
|
||||
CONF_OPTION_GRAB(0, "grab-copy", &wlt_conf.grab_copy, &def_grab_copy),
|
||||
CONF_OPTION_GRAB(0, "grab-paste", &wlt_conf.grab_paste, &def_grab_paste),
|
||||
|
||||
CONF_OPTION_STRING(0, "font-engine", NULL, NULL, &wlt_conf.font_engine, "pango"),
|
||||
CONF_OPTION_UINT(0, "font-size", NULL, NULL, &wlt_conf.font_size, 12),
|
||||
CONF_OPTION_STRING(0, "font-name", NULL, NULL, &wlt_conf.font_name, "monospace"),
|
||||
CONF_OPTION_UINT(0, "font-dpi", NULL, NULL, &wlt_conf.font_ppi, 96),
|
||||
CONF_OPTION_STRING(0, "font-engine", &wlt_conf.font_engine, "pango"),
|
||||
CONF_OPTION_UINT(0, "font-size", &wlt_conf.font_size, 12),
|
||||
CONF_OPTION_STRING(0, "font-name", &wlt_conf.font_name, "monospace"),
|
||||
CONF_OPTION_UINT(0, "font-dpi", &wlt_conf.font_ppi, 96),
|
||||
|
||||
CONF_OPTION_UINT(0, "xkb-repeat-delay", NULL, NULL, &wlt_conf.xkb_repeat_delay, 250),
|
||||
CONF_OPTION_UINT(0, "xkb-repeat-rate", NULL, NULL, &wlt_conf.xkb_repeat_rate, 50),
|
||||
CONF_OPTION_UINT(0, "xkb-repeat-delay", &wlt_conf.xkb_repeat_delay, 250),
|
||||
CONF_OPTION_UINT(0, "xkb-repeat-rate", &wlt_conf.xkb_repeat_rate, 50),
|
||||
};
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
Loading…
x
Reference in New Issue
Block a user