X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=libudev%2Flibudev.c;h=0ae5a9115ac4297828e0dc7cd7aa78226510a446;hp=6645298544074ceb5f179d0d09308c69107c68db;hb=dbba7e4029e2eb8157232e6b5ddd9ee0f68b51b5;hpb=119f66fc36b4f5164fb4a9ece247938e97609a05 diff --git a/libudev/libudev.c b/libudev/libudev.c index 664529854..0ae5a9115 100644 --- a/libudev/libudev.c +++ b/libudev/libudev.c @@ -1,7 +1,7 @@ /* * libudev - interface to udev device information * - * Copyright (C) 2008 Kay Sievers + * Copyright (C) 2008-2010 Kay Sievers * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -21,6 +21,19 @@ #include "libudev.h" #include "libudev-private.h" +/** + * SECTION:libudev + * @short_description: libudev context + * + * The context contains the default values read from the udev config file, + * and is passed to all library operations. + */ + +/** + * udev: + * + * Opaque object representing the library context. + */ struct udev { int refcount; void (*log_fn)(struct udev *udev, @@ -32,7 +45,6 @@ struct udev { char *rules_path; struct udev_list_node properties_list; int log_priority; - int run; }; void udev_log(struct udev *udev, @@ -54,6 +66,15 @@ static void log_stderr(struct udev *udev, vfprintf(stderr, format, args); } +/** + * udev_get_userdata: + * @udev: udev library context + * + * Retrieve stored data pointer from library context. This might be useful + * to access from callbacks like a custom logging function. + * + * Returns: stored userdata + **/ void *udev_get_userdata(struct udev *udev) { if (udev == NULL) @@ -61,6 +82,13 @@ void *udev_get_userdata(struct udev *udev) return udev->userdata; } +/** + * udev_set_userdata: + * @udev: udev library context + * @userdata: data pointer + * + * Store custom @userdata in the library context. + **/ void udev_set_userdata(struct udev *udev, void *userdata) { if (udev == NULL) @@ -71,7 +99,8 @@ void udev_set_userdata(struct udev *udev, void *userdata) /** * udev_new: * - * Create udev library context. + * Create udev library context. This reads the udev configuration + * file, and fills in the default values. * * The initial refcount is 1, and needs to be decremented to * release the resources of the udev library context. @@ -92,8 +121,7 @@ struct udev *udev_new(void) udev->log_fn = log_stderr; udev->log_priority = LOG_ERR; udev_list_init(&udev->properties_list); - udev->run = 1; - udev->dev_path = strdup(UDEV_PREFIX "/dev"); + udev->dev_path = strdup("/dev"); udev->sys_path = strdup("/sys"); config_file = strdup(SYSCONFDIR "/udev/udev.conf"); if (udev->dev_path == NULL || @@ -110,10 +138,6 @@ struct udev *udev_new(void) udev_add_property(udev, "SYSFS_PATH", udev->sys_path); } - env = getenv("UDEV_RUN"); - if (env != NULL && strcmp(env, "0") == 0) - udev->run = 0; - env = getenv("UDEV_CONFIG_FILE"); if (env != NULL) { free(config_file); @@ -293,11 +317,28 @@ void udev_set_log_fn(struct udev *udev, info(udev, "custom logging function %p registered\n", udev); } +/** + * udev_get_log_priority: + * @udev: udev library context + * + * The initial logging priority is read from the udev config file + * at startup. + * + * Returns: the current logging priority + **/ int udev_get_log_priority(struct udev *udev) { return udev->log_priority; } +/** + * udev_set_log_priority: + * @udev: udev library context + * @priority: the new logging priority + * + * Set the current logging priority. The value controls which messages + * are logged. + **/ void udev_set_log_priority(struct udev *udev, int priority) { char num[32]; @@ -312,11 +353,6 @@ const char *udev_get_rules_path(struct udev *udev) return udev->rules_path; } -int udev_get_run(struct udev *udev) -{ - return udev->run; -} - /** * udev_get_sys_path: * @udev: udev library context