chiark / gitweb /
[PATCH] udevsend now almost compiles with klibc, struct sockaddr_un is only problem...
[elogind.git] / udev_config.c
index 44b5767..6d39d29 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Userspace devfs
  *
- * Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com>
+ * Copyright (C) 2003,2004 Greg Kroah-Hartman <greg@kroah.com>
  *
  *
  *     This program is free software; you can redistribute it and/or modify it
@@ -45,7 +45,9 @@ char udev_db_filename[PATH_MAX+NAME_MAX];
 char udev_permissions_filename[PATH_MAX+NAME_MAX];
 char udev_rules_filename[PATH_MAX+NAME_MAX];
 char udev_config_filename[PATH_MAX+NAME_MAX];
-char default_mode_str[NAME_MAX];
+char default_mode_str[MODE_SIZE];
+char default_owner_str[OWNER_SIZE];
+char default_group_str[GROUP_SIZE];
 
 
 static void init_variables(void)
@@ -66,6 +68,41 @@ static void init_variables(void)
                strncpy(_var, value, sizeof(_var));     \
        }
 
+int parse_get_pair(char **orig_string, char **left, char **right)
+{
+       char *temp;
+       char *string = *orig_string;
+
+       if (!string)
+               return -ENODEV;
+
+       /* eat any whitespace */
+       while (isspace(*string) || *string == ',')
+               ++string;
+
+       /* split based on '=' */
+       temp = strsep(&string, "=");
+       *left = temp;
+       if (!string)
+               return -ENODEV;
+
+       /* take the right side and strip off the '"' */
+       while (isspace(*string))
+               ++string;
+       if (*string == '"')
+               ++string;
+       else
+               return -ENODEV;
+
+       temp = strsep(&string, "\"");
+       if (!string || *temp == '\0')
+               return -ENODEV;
+       *right = temp;
+       *orig_string = string;
+       
+       return 0;
+}
+
 static int parse_config_file(void)
 {
        char line[255];
@@ -106,7 +143,7 @@ static int parse_config_file(void)
                if (*temp == COMMENT_CHARACTER)
                        continue;
 
-               retval = get_pair(&temp, &variable, &value);
+               retval = parse_get_pair(&temp, &variable, &value);
                if (retval)
                        break;
                
@@ -117,6 +154,8 @@ static int parse_config_file(void)
                set_var("udev_rules", udev_rules_filename);
                set_var("udev_permissions", udev_permissions_filename);
                set_var("default_mode", default_mode_str);
+               set_var("default_owner", default_owner_str);
+               set_var("default_group", default_group_str);
        }
        dbg_parse("%s:%d:%Zd: error parsing '%s'", udev_config_filename,
                  lineno, temp - line, temp);