*
* 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>
* 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
**/
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;
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:
* @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)
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);
}
* @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,
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);