chiark / gitweb /
remove unused variable
[elogind.git] / src / libudev / libudev-private.h
1 /***
2   This file is part of systemd.
3
4   Copyright 2008-2012 Kay Sievers <kay@vrfy.org>
5
6   systemd is free software; you can redistribute it and/or modify it
7   under the terms of the GNU Lesser General Public License as published by
8   the Free Software Foundation; either version 2.1 of the License, or
9   (at your option) any later version.
10
11   systemd is distributed in the hope that it will be useful, but
12   WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14   Lesser General Public License for more details.
15
16   You should have received a copy of the GNU Lesser General Public License
17   along with systemd; If not, see <http://www.gnu.org/licenses/>.
18 ***/
19
20 #ifndef _LIBUDEV_PRIVATE_H_
21 #define _LIBUDEV_PRIVATE_H_
22
23 #include <syslog.h>
24 #include <signal.h>
25 #include <stdint.h>
26 #include <stdbool.h>
27
28 #include "libudev.h"
29 #include "macro.h"
30 #include "util.h"
31 #include "mkdir.h"
32 #include "strxcpyx.h"
33
34 #define READ_END  0
35 #define WRITE_END 1
36
37 /* avoid (sometimes expensive) calculations of parameters for debug output */
38 #define udev_log_cond(udev, prio, arg...) \
39   do { \
40     if (udev_get_log_priority(udev) >= prio) \
41       udev_log(udev, prio, __FILE__, __LINE__, __FUNCTION__, ## arg); \
42   } while (0)
43
44 #define udev_dbg(udev, arg...) udev_log_cond(udev, LOG_DEBUG, ## arg)
45 #define udev_info(udev, arg...) udev_log_cond(udev, LOG_INFO, ## arg)
46 #define udev_err(udev, arg...) udev_log_cond(udev, LOG_ERR, ## arg)
47
48 /* libudev.c */
49 void udev_log(struct udev *udev,
50               int priority, const char *file, int line, const char *fn,
51               const char *format, ...) _printf_(6, 7);
52 int udev_get_rules_path(struct udev *udev, char **path[], usec_t *ts_usec[]);
53 struct udev_list_entry *udev_add_property(struct udev *udev, const char *key, const char *value);
54 struct udev_list_entry *udev_get_properties_list_entry(struct udev *udev);
55
56 /* libudev-device.c */
57 struct udev_device *udev_device_new(struct udev *udev);
58 mode_t udev_device_get_devnode_mode(struct udev_device *udev_device);
59 uid_t udev_device_get_devnode_uid(struct udev_device *udev_device);
60 gid_t udev_device_get_devnode_gid(struct udev_device *udev_device);
61 int udev_device_set_subsystem(struct udev_device *udev_device, const char *subsystem);
62 int udev_device_set_syspath(struct udev_device *udev_device, const char *syspath);
63 int udev_device_add_devlink(struct udev_device *udev_device, const char *devlink);
64 void udev_device_cleanup_devlinks_list(struct udev_device *udev_device);
65 struct udev_list_entry *udev_device_add_property(struct udev_device *udev_device, const char *key, const char *value);
66 void udev_device_add_property_from_string_parse(struct udev_device *udev_device, const char *property);
67 int udev_device_add_property_from_string_parse_finish(struct udev_device *udev_device);
68 char **udev_device_get_properties_envp(struct udev_device *udev_device);
69 ssize_t udev_device_get_properties_monitor_buf(struct udev_device *udev_device, const char **buf);
70 int udev_device_read_db(struct udev_device *udev_device, const char *dbfile);
71 int udev_device_read_uevent_file(struct udev_device *udev_device);
72 int udev_device_set_action(struct udev_device *udev_device, const char *action);
73 const char *udev_device_get_devpath_old(struct udev_device *udev_device);
74 const char *udev_device_get_id_filename(struct udev_device *udev_device);
75 void udev_device_set_is_initialized(struct udev_device *udev_device);
76 int udev_device_add_tag(struct udev_device *udev_device, const char *tag);
77 void udev_device_cleanup_tags_list(struct udev_device *udev_device);
78 usec_t udev_device_get_usec_initialized(struct udev_device *udev_device);
79 void udev_device_set_usec_initialized(struct udev_device *udev_device, usec_t usec_initialized);
80 int udev_device_get_devlink_priority(struct udev_device *udev_device);
81 int udev_device_set_devlink_priority(struct udev_device *udev_device, int prio);
82 int udev_device_get_watch_handle(struct udev_device *udev_device);
83 int udev_device_set_watch_handle(struct udev_device *udev_device, int handle);
84 int udev_device_get_ifindex(struct udev_device *udev_device);
85 void udev_device_set_info_loaded(struct udev_device *device);
86 bool udev_device_get_db_persist(struct udev_device *udev_device);
87 void udev_device_set_db_persist(struct udev_device *udev_device);
88
89 /* libudev-device-private.c */
90 int udev_device_update_db(struct udev_device *udev_device);
91 int udev_device_delete_db(struct udev_device *udev_device);
92 int udev_device_tag_index(struct udev_device *dev, struct udev_device *dev_old, bool add);
93
94 /* libudev-monitor.c - netlink/unix socket communication  */
95 int udev_monitor_disconnect(struct udev_monitor *udev_monitor);
96 int udev_monitor_allow_unicast_sender(struct udev_monitor *udev_monitor, struct udev_monitor *sender);
97 int udev_monitor_send_device(struct udev_monitor *udev_monitor,
98                              struct udev_monitor *destination, struct udev_device *udev_device);
99 struct udev_monitor *udev_monitor_new_from_netlink_fd(struct udev *udev, const char *name, int fd);
100
101 /* libudev-list.c */
102 struct udev_list_node {
103         struct udev_list_node *next, *prev;
104 };
105 struct udev_list {
106         struct udev *udev;
107         struct udev_list_node node;
108         struct udev_list_entry **entries;
109         unsigned int entries_cur;
110         unsigned int entries_max;
111         bool unique;
112 };
113 #define UDEV_LIST(list) struct udev_list_node list = { &(list), &(list) }
114 void udev_list_node_init(struct udev_list_node *list);
115 int udev_list_node_is_empty(struct udev_list_node *list);
116 void udev_list_node_append(struct udev_list_node *new, struct udev_list_node *list);
117 void udev_list_node_remove(struct udev_list_node *entry);
118 #define udev_list_node_foreach(node, list) \
119         for (node = (list)->next; \
120              node != list; \
121              node = (node)->next)
122 #define udev_list_node_foreach_safe(node, tmp, list) \
123         for (node = (list)->next, tmp = (node)->next; \
124              node != list; \
125              node = tmp, tmp = (tmp)->next)
126 void udev_list_init(struct udev *udev, struct udev_list *list, bool unique);
127 void udev_list_cleanup(struct udev_list *list);
128 struct udev_list_entry *udev_list_get_entry(struct udev_list *list);
129 struct udev_list_entry *udev_list_entry_add(struct udev_list *list, const char *name, const char *value);
130 void udev_list_entry_delete(struct udev_list_entry *entry);
131 int udev_list_entry_get_num(struct udev_list_entry *list_entry);
132 void udev_list_entry_set_num(struct udev_list_entry *list_entry, int num);
133 #define udev_list_entry_foreach_safe(entry, tmp, first) \
134         for (entry = first, tmp = udev_list_entry_get_next(entry); \
135              entry != NULL; \
136              entry = tmp, tmp = udev_list_entry_get_next(tmp))
137
138 /* libudev-queue.c */
139 unsigned long long int udev_get_kernel_seqnum(struct udev *udev);
140 int udev_queue_read_seqnum(FILE *queue_file, unsigned long long int *seqnum);
141 ssize_t udev_queue_read_devpath(FILE *queue_file, char *devpath, size_t size);
142 ssize_t udev_queue_skip_devpath(FILE *queue_file);
143
144 /* libudev-queue-private.c */
145 struct udev_queue_export *udev_queue_export_new(struct udev *udev);
146 struct udev_queue_export *udev_queue_export_unref(struct udev_queue_export *udev_queue_export);
147 void udev_queue_export_cleanup(struct udev_queue_export *udev_queue_export);
148 int udev_queue_export_device_queued(struct udev_queue_export *udev_queue_export, struct udev_device *udev_device);
149 int udev_queue_export_device_finished(struct udev_queue_export *udev_queue_export, struct udev_device *udev_device);
150
151 /* libudev-hwdb.c */
152 bool udev_hwdb_validate(struct udev_hwdb *hwdb);
153
154 /* libudev-util.c */
155 #define UTIL_PATH_SIZE                      1024
156 #define UTIL_NAME_SIZE                       512
157 #define UTIL_LINE_SIZE                     16384
158 #define UDEV_ALLOWED_CHARS_INPUT        "/ $%?,"
159 ssize_t util_get_sys_core_link_value(struct udev *udev, const char *slink, const char *syspath, char *value, size_t size);
160 int util_resolve_sys_link(struct udev *udev, char *syspath, size_t size);
161 int util_log_priority(const char *priority);
162 size_t util_path_encode(const char *src, char *dest, size_t size);
163 void util_remove_trailing_chars(char *path, char c);
164 int util_replace_whitespace(const char *str, char *to, size_t len);
165 int util_replace_chars(char *str, const char *white);
166 unsigned int util_string_hash32(const char *key);
167 uint64_t util_string_bloom64(const char *str);
168
169 /* libudev-util-private.c */
170 int util_delete_path(struct udev *udev, const char *path);
171 uid_t util_lookup_user(struct udev *udev, const char *user);
172 gid_t util_lookup_group(struct udev *udev, const char *group);
173 int util_resolve_subsys_kernel(struct udev *udev, const char *string, char *result, size_t maxsize, int read_value);
174 ssize_t print_kmsg(const char *fmt, ...) _printf_(1, 2);
175
176 #endif