1#![allow(non_camel_case_types)]
2
3extern crate libc;
4
5use libc::{c_void,c_int,c_char,c_ulonglong,size_t,dev_t};
6
7#[cfg(hwdb)]
8pub use hwdb::*;
9
10
11#[repr(C)]
12pub struct udev {
13 __private: c_void,
14}
15
16#[repr(C)]
17pub struct udev_list_entry {
18 __private: c_void,
19}
20
21#[repr(C)]
22pub struct udev_device {
23 __private: c_void,
24}
25
26#[repr(C)]
27pub struct udev_monitor {
28 __private: c_void,
29}
30
31#[repr(C)]
32pub struct udev_enumerate {
33 __private: c_void,
34}
35
36#[repr(C)]
37pub struct udev_queue {
38 __private: c_void,
39}
40
41extern "C" {
42 // udev
43 pub fn udev_new() -> *mut udev;
44 pub fn udev_ref(udev: *mut udev) -> *mut udev;
45 pub fn udev_unref(udev: *mut udev) -> *mut udev;
46 pub fn udev_set_userdata(udev: *mut udev, userdata: *mut c_void);
47 pub fn udev_get_userdata(udev: *mut udev) -> *mut c_void;
48
49 // udev_list
50 pub fn udev_list_entry_get_next(list_entry: *mut udev_list_entry) -> *mut udev_list_entry;
51 pub fn udev_list_entry_get_by_name(list_entry: *mut udev_list_entry, name: *const c_char) -> *mut udev_list_entry;
52 pub fn udev_list_entry_get_name(list_entry: *mut udev_list_entry) -> *const c_char;
53 pub fn udev_list_entry_get_value(list_entry: *mut udev_list_entry) -> *const c_char;
54
55 // udev_device
56 pub fn udev_device_ref(udev_device: *mut udev_device) -> *mut udev_device;
57 pub fn udev_device_unref(udev_device: *mut udev_device) -> *mut udev_device;
58 pub fn udev_device_get_udev(udev_device: *mut udev_device) -> *mut udev;
59 pub fn udev_device_new_from_syspath(udev: *mut udev, syspath: *const c_char) -> *mut udev_device;
60 pub fn udev_device_new_from_devnum(udev: *mut udev, dev_type: c_char, devnum: dev_t) -> *mut udev_device;
61 pub fn udev_device_new_from_subsystem_sysname(udev: *mut udev, subsystem: *const c_char, sysname: *const c_char) -> *mut udev_device;
62 pub fn udev_device_new_from_device_id(udev: *mut udev, id: *const c_char) -> *mut udev_device;
63 pub fn udev_device_new_from_environment(udev: *mut udev) -> *mut udev_device;
64 pub fn udev_device_get_parent(udev_device: *mut udev_device) -> *mut udev_device;
65 pub fn udev_device_get_parent_with_subsystem_devtype(udev_device: *mut udev_device, subsystem: *const c_char, devtype: *const c_char) -> *mut udev_device;
66 pub fn udev_device_get_devpath(udev_device: *mut udev_device) -> *const c_char;
67 pub fn udev_device_get_subsystem(udev_device: *mut udev_device) -> *const c_char;
68 pub fn udev_device_get_devtype(udev_device: *mut udev_device) -> *const c_char;
69 pub fn udev_device_get_syspath(udev_device: *mut udev_device) -> *const c_char;
70 pub fn udev_device_get_sysname(udev_device: *mut udev_device) -> *const c_char;
71 pub fn udev_device_get_sysnum(udev_device: *mut udev_device) -> *const c_char;
72 pub fn udev_device_get_devnode(udev_device: *mut udev_device) -> *const c_char;
73 pub fn udev_device_get_is_initialized(udev_device: *mut udev_device) -> c_int;
74 pub fn udev_device_get_devlinks_list_entry(udev_device: *mut udev_device) -> *mut udev_list_entry;
75 pub fn udev_device_get_properties_list_entry(udev_device: *mut udev_device) -> *mut udev_list_entry;
76 pub fn udev_device_get_tags_list_entry(udev_device: *mut udev_device) -> *mut udev_list_entry;
77 pub fn udev_device_get_property_value(udev_device: *mut udev_device, key: *const c_char) -> *const c_char;
78 pub fn udev_device_get_driver(udev_device: *mut udev_device) -> *const c_char;
79 pub fn udev_device_get_devnum(udev_device: *mut udev_device) -> dev_t;
80 pub fn udev_device_get_action(udev_device: *mut udev_device) -> *const c_char;
81 pub fn udev_device_get_sysattr_value(udev_device: *mut udev_device, sysattr: *const c_char) -> *const c_char;
82 pub fn udev_device_set_sysattr_value(udev_device: *mut udev_device, sysattr: *const c_char, value: *mut c_char) -> c_int;
83 pub fn udev_device_get_sysattr_list_entry(udev_device: *mut udev_device) -> *mut udev_list_entry;
84 pub fn udev_device_get_seqnum(udev_device: *mut udev_device) -> c_ulonglong;
85 pub fn udev_device_get_usec_since_initialized(udev_device: *mut udev_device) -> c_ulonglong;
86 pub fn udev_device_has_tag(udev_device: *mut udev_device, tag: *const c_char) -> c_int;
87
88 // udev_monitor
89 pub fn udev_monitor_ref(udev_monitor: *mut udev_monitor) -> *mut udev_monitor;
90 pub fn udev_monitor_unref(udev_monitor: *mut udev_monitor) -> *mut udev_monitor;
91 pub fn udev_monitor_get_udev(udev_monitor: *mut udev_monitor) -> *mut udev;
92 pub fn udev_monitor_new_from_netlink(udev: *mut udev, name: *const c_char) -> *mut udev_monitor;
93 pub fn udev_monitor_enable_receiving(udev_monitor: *mut udev_monitor) -> c_int;
94 pub fn udev_monitor_set_receive_buffer_size(udev_monitor: *mut udev_monitor, size: c_int) -> c_int;
95 pub fn udev_monitor_get_fd(udev_monitor: *mut udev_monitor) -> c_int;
96 pub fn udev_monitor_receive_device(udev_monitor: *mut udev_monitor) -> *mut udev_device;
97 pub fn udev_monitor_filter_add_match_subsystem_devtype(udev_monitor: *mut udev_monitor, subsystem: *const c_char, devtype: *const c_char) -> c_int;
98 pub fn udev_monitor_filter_add_match_tag(udev_monitor: *mut udev_monitor, tag: *const c_char) -> c_int;
99 pub fn udev_monitor_filter_update(udev_monitor: *mut udev_monitor) -> c_int;
100 pub fn udev_monitor_filter_remove(udev_monitor: *mut udev_monitor) -> c_int;
101
102 // udev_enumerate
103 pub fn udev_enumerate_ref(udev_enumerate: *mut udev_enumerate) -> *mut udev_enumerate;
104 pub fn udev_enumerate_unref(udev_enumerate: *mut udev_enumerate) -> *mut udev_enumerate;
105 pub fn udev_enumerate_get_udev(udev_enumerate: *mut udev_enumerate) -> *mut udev;
106 pub fn udev_enumerate_new(udev: *mut udev) -> *mut udev_enumerate;
107 pub fn udev_enumerate_add_match_subsystem(udev_enumerate: *mut udev_enumerate, subsystem: *const c_char) -> c_int;
108 pub fn udev_enumerate_add_nomatch_subsystem(udev_enumerate: *mut udev_enumerate, subsystem: *const c_char) -> c_int;
109 pub fn udev_enumerate_add_match_sysattr(udev_enumerate: *mut udev_enumerate, sysattr: *const c_char, value: *const c_char) -> c_int;
110 pub fn udev_enumerate_add_nomatch_sysattr(udev_enumerate: *mut udev_enumerate, sysattr: *const c_char, value: *const c_char) -> c_int;
111 pub fn udev_enumerate_add_match_property(udev_enumerate: *mut udev_enumerate, property: *const c_char, value: *const c_char) -> c_int;
112 pub fn udev_enumerate_add_match_tag(udev_enumerate: *mut udev_enumerate, tag: *const c_char) -> c_int;
113 pub fn udev_enumerate_add_match_parent(udev_enumerate: *mut udev_enumerate, parent: *mut udev_device) -> c_int;
114 pub fn udev_enumerate_add_match_is_initialized(udev_enumerate: *mut udev_enumerate) -> c_int;
115 pub fn udev_enumerate_add_match_sysname(udev_enumerate: *mut udev_enumerate, sysname: *const c_char) -> c_int;
116 pub fn udev_enumerate_add_syspath(udev_enumerate: *mut udev_enumerate, syspath: *const c_char) -> c_int;
117 pub fn udev_enumerate_scan_devices(udev_enumerate: *mut udev_enumerate) -> c_int;
118 pub fn udev_enumerate_scan_subsystems(udev_enumerate: *mut udev_enumerate) -> c_int;
119 pub fn udev_enumerate_get_list_entry(udev_enumerate: *mut udev_enumerate) -> *mut udev_list_entry;
120
121 // udev_queue
122 pub fn udev_queue_ref(udev_queue: *mut udev_queue) -> *mut udev_queue;
123 pub fn udev_queue_unref(udev_queue: *mut udev_queue) -> *mut udev_queue;
124 pub fn udev_queue_get_udev(udev_queue: *mut udev_queue) -> *mut udev;
125 pub fn udev_queue_new(udev: *mut udev) -> *mut udev_queue;
126 pub fn udev_queue_get_udev_is_active(udev_queue: *mut udev_queue) -> c_int;
127 pub fn udev_queue_get_queue_is_empty(udev_queue: *mut udev_queue) -> c_int;
128 pub fn udev_queue_get_fd(udev_queue: *mut udev_queue) -> c_int;
129 pub fn udev_queue_flush(udev_queue: *mut udev_queue) -> c_int;
130
131 // udev_util
132 pub fn udev_util_encode_string(str: *const c_char, str_enc: *mut c_char, len: size_t) -> c_int;
133}
134
135
136#[cfg(hwdb)]
137mod hwdb {
138 use super::libc::{c_void,c_uint,c_char};
139 use super::{udev,udev_list_entry};
140
141 #[repr(C)]
142 pub struct udev_hwdb {
143 __private: c_void,
144 }
145
146 extern "C" {
147 pub fn udev_hwdb_ref(hwdb: *mut udev_hwdb) -> *mut udev_hwdb;
148 pub fn udev_hwdb_unref(hwdb: *mut udev_hwdb) -> *mut udev_hwdb;
149 pub fn udev_hwdb_new(udev: *mut udev) -> *mut udev_hwdb;
150 pub fn udev_hwdb_get_properties_list_entry(hwdb: *mut udev_hwdb, modalias: *const c_char, flags: c_uint) -> *mut udev_list_entry;
151 }
152}
153