Oops, fix up my previous commit properly.
[dragonfly.git] / lib / libdevattr / devattr.h
blob2878102cee04b2801ddd2bdbf33f45d77ec95b68
1 /*
2 * Copyright (c) 2010 The DragonFly Project. All rights reserved.
4 * This code is derived from software contributed to The DragonFly Project
5 * by Alex Hornung <ahornung@gmail.com>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 * 3. Neither the name of The DragonFly Project nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific, prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
34 #include <sys/queue.h>
35 #include <libprop/proplib.h>
36 #include <cpu/atomic.h>
38 struct udev;
39 struct udev_enumerate;
40 struct udev_list_entry;
41 struct udev_monitor;
42 struct udev_device;
44 struct udev *udev_new(void);
45 struct udev *udev_ref(struct udev *udev_ctx);
46 void udev_unref(struct udev *udev_ctx);
47 const char *udev_get_dev_path(struct udev *udev_ctx);
48 void *udev_get_userdata(struct udev *udev_ctx);
49 void udev_set_userdata(struct udev *udev_ctx, void *userdata);
50 #ifdef LIBDEVATTR_INTERNAL
51 int udev_get_fd(struct udev *udev_ctx);
52 #endif
54 struct udev_device *udev_device_new_from_dictionary(struct udev *udev_ctx, prop_dictionary_t dict);
55 struct udev_device *udev_device_ref(struct udev_device *udev_device);
56 void udev_device_unref(struct udev_device *udev_device);
57 prop_dictionary_t udev_device_get_dictionary(struct udev_device *udev_device);
58 struct udev *udev_device_get_udev(struct udev_device *udev_device);
59 void udev_device_set_action(struct udev_device *udev_device, int action);
60 const char *udev_device_get_action(struct udev_device *udev_device);
61 dev_t udev_device_get_devnum(struct udev_device *udev_device);
62 const char *udev_device_get_devnode(struct udev_device *udev_device);
63 const char *udev_device_get_property_value(struct udev_device *udev_device,
64 const char *key);
65 const char *udev_device_get_subsystem(struct udev_device *udev_device);
66 const char *udev_device_get_driver(struct udev_device *udev_device);
67 uint64_t udev_device_get_kptr(struct udev_device *udev_device);
68 int32_t udev_device_get_major(struct udev_device *udev_device);
69 int32_t udev_device_get_minor(struct udev_device *udev_device);
71 struct udev_enumerate *udev_enumerate_new(struct udev *udev_ctx);
72 struct udev_enumerate *udev_enumerate_ref(struct udev_enumerate *udev_enum);
73 void udev_enumerate_unref(struct udev_enumerate *udev_enum);
74 struct udev *udev_enumerate_get_udev(struct udev_enumerate *udev_enum);
75 int udev_enumerate_scan_devices(struct udev_enumerate *udev_enum);
76 struct udev_list_entry *udev_enumerate_get_list_entry(struct udev_enumerate *udev_enum);
77 #define udev_list_entry_foreach(list_entry, first_entry) \
78 for(list_entry = first_entry; \
79 list_entry != NULL; \
80 list_entry = udev_list_entry_get_next(list_entry))
81 prop_array_t udev_enumerate_get_array(struct udev_enumerate *udev_enum);
82 struct udev_list_entry *udev_list_entry_get_next(struct udev_list_entry *list_entry);
83 prop_dictionary_t udev_list_entry_get_dictionary(struct udev_list_entry *list_entry);
84 struct udev_device *udev_list_entry_get_device(struct udev_list_entry *list_entry);
85 #ifdef LIBDEVATTR_INTERNAL
86 int _udev_enumerate_filter_add_match_gen(struct udev_enumerate *udev_enum,
87 int type,
88 int neg,
89 const char *key,
90 char *expr);
91 #endif
92 int udev_enumerate_add_match_subsystem(struct udev_enumerate *udev_enum,
93 const char *subsystem);
94 int udev_enumerate_add_nomatch_subsystem(struct udev_enumerate *udev_enum,
95 const char *subsystem);
96 int udev_enumerate_add_match_expr(struct udev_enumerate *udev_enum,
97 const char *key,
98 char *expr);
99 int udev_enumerate_add_nomatch_expr(struct udev_enumerate *udev_enum,
100 const char *key,
101 char *expr);
102 int udev_enumerate_add_match_regex(struct udev_enumerate *udev_enum,
103 const char *key,
104 char *expr);
105 int udev_enumerate_add_nomatch_regex(struct udev_enumerate *udev_enum,
106 const char *key,
107 char *expr);
108 #define udev_enumerate_add_match_property(x, a, b) \
109 udev_enumerate_add_match_expr((x), (a), __DECONST(char *, (b)))
111 #define udev_enumerate_add_nomatch_property(x, a, b) \
112 udev_enumerate_add_nomatch_expr((x), (a), __DECONST(char *, (b)))
114 struct udev_monitor *udev_monitor_new(struct udev *udev_ctx);
115 struct udev_monitor *udev_monitor_ref(struct udev_monitor *udev_monitor);
116 void udev_monitor_unref(struct udev_monitor *udev_monitor);
117 struct udev *udev_monitor_get_udev(struct udev_monitor *udev_monitor);
118 int udev_monitor_get_fd(struct udev_monitor *udev_monitor);
119 struct udev_device *udev_monitor_receive_device(struct udev_monitor *udev_monitor);
120 int udev_monitor_enable_receiving(struct udev_monitor *udev_monitor);
121 int udev_monitor_filter_add_match_subsystem_devtype(struct udev_monitor *udev_monitor,
122 const char *subsystem,
123 const char *devtype);
124 int udev_monitor_filter_add_match_expr(struct udev_monitor *udev_monitor,
125 const char *key,
126 char *expr);
127 int udev_monitor_filter_add_nomatch_expr(struct udev_monitor *udev_monitor,
128 const char *key,
129 char *expr);
130 int udev_monitor_filter_add_match_regex(struct udev_monitor *udev_monitor,
131 const char *key,
132 char *expr);
133 int udev_monitor_filter_add_nomatch_regex(struct udev_monitor *udev_monitor,
134 const char *key,
135 char *expr);
136 #define udev_monitor_filter_add_match_property(x, a, b) \
137 udev_monitor_filter_add_match_expr((x), (a), __DECONST(char *, (b)))
139 #define udev_monitor_filter_add_nomatch_property(x, a, b) \
140 udev_monitor_filter_add_nomatch_expr((x), (a), __DECONST(char *, (b)))
142 #ifdef LIBDEVATTR_INTERNAL
143 int _udev_monitor_filter_add_match_gen(struct udev_monitor *udev_monitor,
144 int type,
145 int neg,
146 const char *key,
147 char *expr);
148 int _udev_filter_add_match_gen(prop_array_t filters,
149 int type,
150 int neg,
151 const char *key,
152 char *expr);
153 #endif
155 #ifdef LIBDEVATTR_INTERNAL
156 int send_xml(int s, char *xml);
157 int read_xml(int s, char **buf);
158 int _udev_dict_set_cstr(prop_dictionary_t dict, const char *key, char *str);
159 int _udev_dict_set_int(prop_dictionary_t dict, const char *key, int64_t val);
160 int _udev_dict_set_uint(prop_dictionary_t dict, const char *key, uint64_t val);
161 int conn_local_server(const char *sockfile, int socktype, int nonblock,
162 int *retsock);
163 prop_dictionary_t udevd_get_command_dict(char *command);
164 prop_array_t udevd_request_devs(int s, prop_array_t filters);
165 #endif