summaryrefslogtreecommitdiff
path: root/udev_config.c
diff options
context:
space:
mode:
authorgreg@kroah.com <greg@kroah.com>2004-02-11 22:10:26 -0800
committerGreg KH <gregkh@suse.de>2005-04-26 21:32:26 -0700
commit51a8bb2f361d86013e7579570faba446eed9c66d (patch)
treee2ac4dc12e0608edec3731f1764873958b835add /udev_config.c
parent4d803d8d04a8493f8efc039c7789c65be33048a0 (diff)
[PATCH] fix log option code so that it actually works for all udev programs.
Also introduce boolean type for config file to use.
Diffstat (limited to 'udev_config.c')
-rw-r--r--udev_config.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/udev_config.c b/udev_config.c
index ec38272bc5..34ef82b881 100644
--- a/udev_config.c
+++ b/udev_config.c
@@ -48,9 +48,18 @@ char udev_config_filename[PATH_MAX+NAME_MAX];
char default_mode_str[MODE_SIZE];
char default_owner_str[OWNER_SIZE];
char default_group_str[GROUP_SIZE];
-char udev_log_str[BOOL_SIZE];
+int udev_log;
+static int string_is_true(char *str)
+{
+ if (strcasecmp(str, "true") == 0)
+ return 1;
+ if (strcasecmp(str, "yes") == 0)
+ return 1;
+ return 0;
+}
+
static void init_variables(void)
{
/* fill up the defaults.
@@ -61,7 +70,7 @@ static void init_variables(void)
strfieldcpy(udev_config_filename, UDEV_CONFIG_FILE);
strfieldcpy(udev_rules_filename, UDEV_RULES_FILE);
strfieldcpy(udev_permissions_filename, UDEV_PERMISSION_FILE);
- strfieldcpy(udev_log_str, UDEV_LOG_DEFAULT);
+ udev_log = string_is_true(UDEV_LOG_DEFAULT);
}
#define set_var(_name, _var) \
@@ -70,6 +79,12 @@ static void init_variables(void)
strncpy(_var, value, sizeof(_var)); \
}
+#define set_bool(_name, _var) \
+ if (strcasecmp(variable, _name) == 0) { \
+ dbg_parse("%s = '%s'", _name, value); \
+ _var = string_is_true(value); \
+ }
+
int parse_get_pair(char **orig_string, char **left, char **right)
{
char *temp;
@@ -158,7 +173,7 @@ static int parse_config_file(void)
set_var("default_mode", default_mode_str);
set_var("default_owner", default_owner_str);
set_var("default_group", default_group_str);
- set_var("udev_log", udev_log_str);
+ set_bool("udev_log", udev_log);
}
dbg_parse("%s:%d:%Zd: error parsing '%s'", udev_config_filename,
lineno, temp - line, temp);
@@ -194,7 +209,7 @@ static void get_dirs(void)
dbg_parse("udev_db_filename = %s", udev_db_filename);
dbg_parse("udev_rules_filename = %s", udev_rules_filename);
dbg_parse("udev_permissions_filename = %s", udev_permissions_filename);
- dbg_parse("udev_log_str = %s", udev_log_str);
+ dbg_parse("udev_log = %d", udev_log);
parse_config_file();
dbg_parse("udev_root = %s", udev_root);
@@ -202,7 +217,7 @@ static void get_dirs(void)
dbg_parse("udev_db_filename = %s", udev_db_filename);
dbg_parse("udev_rules_filename = %s", udev_rules_filename);
dbg_parse("udev_permissions_filename = %s", udev_permissions_filename);
- dbg_parse("udev_log_str = %s", udev_log_str);
+ dbg_parse("udev_log_str = %d", udev_log);
}
void udev_init_config(void)