summaryrefslogtreecommitdiff
path: root/udev_config.c
diff options
context:
space:
mode:
authorgreg@kroah.com <greg@kroah.com>2004-01-26 19:21:58 -0800
committerGreg KH <gregkh@suse.de>2005-04-26 21:13:19 -0700
commit274812b502089c55acb1bc7bfe99bebf9ce669b2 (patch)
treeacf556c4be8e615c4e660664900f799fdf3a8cc3 /udev_config.c
parent1f6d07b9a5d97183a20f3d07619e2f9aa31510f0 (diff)
[PATCH] move get_pair to udev_config.c because udevinfo doesn't need all of namedev.o
Diffstat (limited to 'udev_config.c')
-rw-r--r--udev_config.c39
1 files changed, 37 insertions, 2 deletions
diff --git a/udev_config.c b/udev_config.c
index e75ee3a346..6d39d294e1 100644
--- a/udev_config.c
+++ b/udev_config.c
@@ -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
@@ -68,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];
@@ -108,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;