chiark / gitweb /
[PATCH] move get_pair to udev_config.c because udevinfo doesn't need all of namedev.o
authorgreg@kroah.com <greg@kroah.com>
Tue, 27 Jan 2004 03:21:58 +0000 (19:21 -0800)
committerGreg KH <gregkh@suse.de>
Wed, 27 Apr 2005 04:13:19 +0000 (21:13 -0700)
namedev.h
namedev_parse.c
udev.h
udev_config.c

index 42b1e6c1a0a1cabd4db09d9729bf2e2ab160967f..9cff3710d40554f86d7ee9de70bd8afb1cce8697 100644 (file)
--- a/namedev.h
+++ b/namedev.h
@@ -3,7 +3,7 @@
  *
  * Userspace devfs
  *
  *
  * 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
  *     under the terms of the GNU General Public License as published by the
  *
  *     This program is free software; you can redistribute it and/or modify it
  *     under the terms of the GNU General Public License as published by the
@@ -91,6 +91,4 @@ extern void dump_config_dev_list(void);
 extern void dump_perm_dev(struct perm_device *dev);
 extern void dump_perm_dev_list(void);
 
 extern void dump_perm_dev(struct perm_device *dev);
 extern void dump_perm_dev_list(void);
 
-extern int get_pair(char **orig_string, char **left, char **right);
-
 #endif
 #endif
index b15be0e6fa7d5894c9c8bc0a3a19f07034300a06..e6575fa108431958e33d0a283b2c7bd20935f4ba 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Userspace devfs
  *
  *
  * 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
  *
  *
  *     This program is free software; you can redistribute it and/or modify it
@@ -52,41 +52,6 @@ static int add_config_dev(struct config_device *new_dev)
        return 0;
 }
 
        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 */
 void dump_config_dev(struct config_device *dev)
 {
        /*FIXME dump all sysfs's */
@@ -166,7 +131,7 @@ int namedev_init_rules(void)
 
                /* get all known keys */
                while (1) {
 
                /* get all known keys */
                while (1) {
-                       retval = get_pair(&temp, &temp2, &temp3);
+                       retval = parse_get_pair(&temp, &temp2, &temp3);
                        if (retval)
                                break;
 
                        if (retval)
                                break;
 
diff --git a/udev.h b/udev.h
index e5c983a212c1eb84c6ef6c3e778c29e1dc44bc1b..f854a183d3e49121781ef90f356fa971794c4f6e 100644 (file)
--- a/udev.h
+++ b/udev.h
@@ -59,6 +59,7 @@ do { \
 extern int udev_add_device(char *path, char *subsystem);
 extern int udev_remove_device(char *path, char *subsystem);
 extern void udev_init_config(void);
 extern int udev_add_device(char *path, char *subsystem);
 extern int udev_remove_device(char *path, char *subsystem);
 extern void udev_init_config(void);
+extern int parse_get_pair(char **orig_string, char **left, char **right);
 
 extern char **main_argv;
 extern char **main_envp;
 
 extern char **main_argv;
 extern char **main_envp;
index e75ee3a3468995290d7bf2142c47833604422466..6d39d294e1dba8843e93549eeae839f943fbad6c 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Userspace devfs
  *
  *
  * 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
  *
  *
  *     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));     \
        }
 
                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];
 static int parse_config_file(void)
 {
        char line[255];
@@ -108,7 +143,7 @@ static int parse_config_file(void)
                if (*temp == COMMENT_CHARACTER)
                        continue;
 
                if (*temp == COMMENT_CHARACTER)
                        continue;
 
-               retval = get_pair(&temp, &variable, &value);
+               retval = parse_get_pair(&temp, &variable, &value);
                if (retval)
                        break;
                
                if (retval)
                        break;