From f01a2ad47d7ee64f115faa59dbda6d08998a2acb Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 19 Mar 2008 10:09:22 +0100 Subject: [PATCH] Check for alignment values in configuration file --- common/configopts.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/common/configopts.c b/common/configopts.c index f4cd8ae1b..9fadb2d63 100644 --- a/common/configopts.c +++ b/common/configopts.c @@ -411,7 +411,7 @@ config_validate_position(cfg_t *cfg, cfg_opt_t *opt) char *value = cfg_opt_getnstr(opt, cfg_opt_size(opt) - 1); if(position_get_from_str(value) == Off - && !a_strncmp(value, "off", 3)) + && a_strcmp(value, "off")) { cfg_error(cfg, "position option '%s' must be top, bottom, right, left, auto or off in section '%s'", @@ -421,6 +421,22 @@ config_validate_position(cfg_t *cfg, cfg_opt_t *opt) return 0; } +static int +config_validate_alignment(cfg_t *cfg, cfg_opt_t *opt) +{ + char *value = cfg_opt_getnstr(opt, cfg_opt_size(opt) - 1); + + if(draw_get_align(value) == Auto + && a_strcmp(value, "auto")) + { + cfg_error(cfg, + "alignment option '%s' must be left, center, right, flex or auto in section '%s'", + opt->name, cfg->name); + return -1; + } + return 0; +} + cfg_t * cfg_new(void) { @@ -445,8 +461,13 @@ cfg_new(void) /* Check position values */ cfg_set_validate_func(cfg, "screen|titlebar|position", config_validate_position); + cfg_set_validate_func(cfg, "rules|rule|titlebar|position", config_validate_position); cfg_set_validate_func(cfg, "screen|statusbar|position", config_validate_position); + /* Check alignment values */ + cfg_set_validate_func(cfg, "screen|titlebar|text_align", config_validate_alignment); + cfg_set_validate_func(cfg, "rules|rule|titlebar|text_align", config_validate_alignment); + return cfg; }