*
* 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
*
*/
-/* define this to enable parsing debugging */
+#ifdef DEBUG
+/* define this to enable parsing debugging also */
/* #define DEBUG_PARSER */
+#endif
#include <stddef.h>
#include <stdlib.h>
#include <errno.h>
#include "udev.h"
+#include "logging.h"
#include "namedev.h"
static int add_config_dev(struct config_device *new_dev)
return 0;
}
-int 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;
-}
-
void dump_config_dev(struct config_device *dev)
{
/*FIXME dump all sysfs's */
dump_perm_dev(dev);
}
-
int namedev_init_rules(void)
{
char line[255];
/* get all known keys */
while (1) {
- retval = get_pair(&temp, &temp2, &temp3);
+ retval = parse_get_pair(&temp, &temp2, &temp3);
if (retval)
break;
continue;
}
- dbg_parse("unknown type of field '%s'", temp2);
+ dbg("unknown type of field '%s'", temp2);
+ dbg("You might be using a rules file in the old format, please fix.");
+ goto error;
}
/* simple plausibility check for given keys */
goto error;
}
+ dev.config_line = lineno;
retval = add_config_dev(&dev);
if (retval) {
dbg("add_config_dev returned with error %d", retval);
continue;
error:
- dbg("%s:%d:%Zd: parse error, rule skipped",
+ dbg("%s:%d:%d: parse error, rule skipped",
udev_rules_filename, lineno, temp - line);
}
}
dbg("cannot parse line '%s'", line);
continue;
}
- strncpy(dev.group, temp2, sizeof(dev.owner));
+ strncpy(dev.group, temp2, sizeof(dev.group));
if (!temp) {
dbg("cannot parse line: %s", line);
exit:
fclose(fd);
return retval;
-}
-
+}