]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/libudev/libudev.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
3 This file is part of systemd.
5 Copyright 2008-2014 Kay Sievers <kay@vrfy.org>
17 #include "alloc-util.h"
19 #include "libudev-private.h"
21 #include "string-util.h"
25 * @short_description: libudev context
27 * The context contains the default values read from the udev config file,
28 * and is passed to all library operations.
34 * Opaque object representing the library context.
38 void (*log_fn
)(struct udev
*udev
,
39 int priority
, const char *file
, int line
, const char *fn
,
40 const char *format
, va_list args
);
46 * @udev: udev library context
48 * Retrieve stored data pointer from library context. This might be useful
49 * to access from callbacks.
51 * Returns: stored userdata
53 _public_
void *udev_get_userdata(struct udev
*udev
) {
56 return udev
->userdata
;
61 * @udev: udev library context
62 * @userdata: data pointer
64 * Store custom @userdata in the library context.
66 _public_
void udev_set_userdata(struct udev
*udev
, void *userdata
) {
69 udev
->userdata
= userdata
;
75 * Create udev library context. This only allocates the basic data structure.
77 * The initial refcount is 1, and needs to be decremented to
78 * release the resources of the udev library context.
80 * Returns: a new udev library context
82 _public_
struct udev
*udev_new(void) {
85 udev
= new0(struct udev
, 1);
97 * @udev: udev library context
99 * Take a reference of the udev library context.
101 * Returns: the passed udev library context
103 _public_
struct udev
*udev_ref(struct udev
*udev
) {
112 * @udev: udev library context
114 * Drop a reference of the udev library context. If the refcount
115 * reaches zero, the resources of the context will be released.
117 * Returns: the passed udev library context if it has still an active reference, or #NULL otherwise.
119 _public_
struct udev
*udev_unref(struct udev
*udev
) {
123 if (udev
->refcount
> 0)
130 * @udev: udev library context
131 * @log_fn: function to be called for log messages
133 * This function is deprecated.
136 _public_
void udev_set_log_fn(struct udev
*udev
,
137 void (*log_fn
)(struct udev
*udev
,
138 int priority
, const char *file
, int line
, const char *fn
,
139 const char *format
, va_list args
)) {
144 * udev_get_log_priority:
145 * @udev: udev library context
147 * This function is deprecated.
150 _public_
int udev_get_log_priority(struct udev
*udev
) {
151 return log_get_max_level();
155 * udev_set_log_priority:
156 * @udev: udev library context
157 * @priority: the new log priority
159 * This function is deprecated.
162 _public_
void udev_set_log_priority(struct udev
*udev
, int priority
) {
163 log_set_max_level(priority
);