X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=udev_config.c;h=6d39d294e1dba8843e93549eeae839f943fbad6c;hp=e75ee3a3468995290d7bf2142c47833604422466;hb=e047ca9bdfc3d95cccbbcf6d4f2358648c7d0758;hpb=765cbd97599d943adc73d03f4c91bd7cf7ef7fab diff --git a/udev_config.c b/udev_config.c index e75ee3a34..6d39d294e 100644 --- a/udev_config.c +++ b/udev_config.c @@ -3,7 +3,7 @@ * * Userspace devfs * - * Copyright (C) 2003 Greg Kroah-Hartman + * Copyright (C) 2003,2004 Greg Kroah-Hartman * * * 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;