chiark / gitweb /
libudev: GPL -> LGPL
[elogind.git] / udev / lib / libudev.c
index c698be6e466c3f7bf48d58a84018f9e0b28553ae..2177e5459c5ed016b5388cec95396b2c09570e66 100644 (file)
@@ -3,18 +3,10 @@
  *
  * Copyright (C) 2008 Kay Sievers <kay.sievers@vrfy.org>
  *
- * 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 Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
  */
 
 #include <stdio.h>
@@ -85,7 +77,7 @@ void udev_set_userdata(struct udev *udev, void *userdata)
  * Create udev library context.
  *
  * The initial refcount is 1, and needs to be decremented to
- * release the ressources of the udev library context.
+ * release the resources of the udev library context.
  *
  * Returns: a new udev library context
  **/
@@ -96,10 +88,9 @@ struct udev *udev_new(void)
        char *config_file;
        FILE *f;
 
-       udev = malloc(sizeof(struct udev));
+       udev = calloc(1, sizeof(struct udev));
        if (udev == NULL)
                return NULL;
-       memset(udev, 0x00, (sizeof(struct udev)));
        udev->refcount = 1;
        udev->log_fn = log_stderr;
        udev->log_priority = LOG_ERR;
@@ -198,7 +189,7 @@ struct udev *udev_new(void)
                        }
 
                        if (strcasecmp(key, "udev_log") == 0) {
-                               udev->log_priority = util_log_priority(val);
+                               udev_set_log_priority(udev, util_log_priority(val));
                                continue;
                        }
                        if (strcasecmp(key, "udev_root") == 0) {
@@ -231,13 +222,13 @@ struct udev *udev_new(void)
 
        if (udev->dev_path == NULL || udev->sys_path == NULL)
                goto err;
-       info(udev, "context %p created\n", udev);
-       info(udev, "log_priority=%d\n", udev->log_priority);
-       info(udev, "config_file='%s'\n", config_file);
-       info(udev, "dev_path='%s'\n", udev->dev_path);
-       info(udev, "sys_path='%s'\n", udev->sys_path);
+       dbg(udev, "context %p created\n", udev);
+       dbg(udev, "log_priority=%d\n", udev->log_priority);
+       dbg(udev, "config_file='%s'\n", config_file);
+       dbg(udev, "dev_path='%s'\n", udev->dev_path);
+       dbg(udev, "sys_path='%s'\n", udev->sys_path);
        if (udev->rules_path != NULL)
-               info(udev, "rules_path='%s'\n", udev->rules_path);
+               dbg(udev, "rules_path='%s'\n", udev->rules_path);
        free(config_file);
        return udev;
 err:
@@ -268,7 +259,7 @@ struct udev *udev_ref(struct udev *udev)
  * @udev: udev library context
  *
  * Drop a reference of the udev library context. If the refcount
- * reaches zero, the ressources of the context will be released.
+ * reaches zero, the resources of the context will be released.
  *
  **/
 void udev_unref(struct udev *udev)
@@ -278,11 +269,11 @@ void udev_unref(struct udev *udev)
        udev->refcount--;
        if (udev->refcount > 0)
                return;
-       udev_list_cleanup(udev, &udev->properties_list);
+       udev_list_cleanup_entries(udev, &udev->properties_list);
        free(udev->dev_path);
        free(udev->sys_path);
        free(udev->rules_path);
-       info(udev, "context %p released\n", udev);
+       dbg(udev, "context %p released\n", udev);
        free(udev);
 }
 
@@ -291,9 +282,9 @@ void udev_unref(struct udev *udev)
  * @udev: udev library context
  * @log_fn: function to be called for logging messages
  *
- * The built-in logging, which writes to stderr, it can be
+ * The built-in logging writes to stderr. It can be
  * overridden by a custom function, to plug log messages
- * into the users logging functionality.
+ * into the users' logging functionality.
  *
  **/
 void udev_set_log_fn(struct udev *udev,
@@ -371,7 +362,7 @@ struct udev_list_entry *udev_add_property(struct udev *udev, const char *key, co
                list_entry = udev_get_properties_list_entry(udev);
                list_entry = udev_list_entry_get_by_name(list_entry, key);
                if (list_entry != NULL)
-                       udev_list_entry_remove(list_entry);
+                       udev_list_entry_delete(list_entry);
                return NULL;
        }
        return udev_list_entry_add(udev, &udev->properties_list, key, value, 1, 0);