udev.cpp
Go to the documentation of this file.
1 
2 // Copyright (c) 2003-2021 Xsens Technologies B.V. or subsidiaries worldwide.
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without modification,
6 // are permitted provided that the following conditions are met:
7 //
8 // 1. Redistributions of source code must retain the above copyright notice,
9 // this list of conditions, and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright notice,
12 // this list of conditions, and the following disclaimer in the documentation
13 // and/or other materials provided with the distribution.
14 //
15 // 3. Neither the names of the copyright holders nor the names of their contributors
16 // may be used to endorse or promote products derived from this software without
17 // specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 // THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
24 // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR
26 // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS
28 // SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES
29 // OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE
30 // ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES.
31 //
32 
33 
34 // Copyright (c) 2003-2021 Xsens Technologies B.V. or subsidiaries worldwide.
35 // All rights reserved.
36 //
37 // Redistribution and use in source and binary forms, with or without modification,
38 // are permitted provided that the following conditions are met:
39 //
40 // 1. Redistributions of source code must retain the above copyright notice,
41 // this list of conditions, and the following disclaimer.
42 //
43 // 2. Redistributions in binary form must reproduce the above copyright notice,
44 // this list of conditions, and the following disclaimer in the documentation
45 // and/or other materials provided with the distribution.
46 //
47 // 3. Neither the names of the copyright holders nor the names of their contributors
48 // may be used to endorse or promote products derived from this software without
49 // specific prior written permission.
50 //
51 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
52 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
53 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
54 // THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 // SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
56 // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
57 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR
58 // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
59 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS
60 // SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES
61 // OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE
62 // ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES.
63 //
64 
65 #include "udev.h"
67 
71 Udev::Udev(void)
72 {
73  m_libraryLoader = new XsLibraryLoader();
74  initLibrary();
75 }
76 
77 Udev::~Udev(void)
78 {
79  delete m_libraryLoader;
80 }
81 
82 void Udev::initLibrary()
83 {
84  if (!m_libraryLoader->isLoaded())
85  m_libraryLoader->load("libudev.so");
86 
87  memset(&m_uDev, 0, sizeof(m_uDev));
88 
89  if (m_libraryLoader->isLoaded())
90  {
91  m_uDev.unew = (uDEV_new*)m_libraryLoader->resolve("udev_new");
92  m_uDev.unref = (uDEV_unref*)m_libraryLoader->resolve("udev_unref");
93  m_uDev.device_unref = (uDEV_device_unref*)m_libraryLoader->resolve("udev_device_unref");
94  m_uDev.enumerate_new = (uDEV_enumerate_new*)m_libraryLoader->resolve("udev_enumerate_new");
95  m_uDev.enumerate_add_match_subsystem = (uDEV_enumerate_add_match_subsystem*)m_libraryLoader->resolve("udev_enumerate_add_match_subsystem");
96  m_uDev.enumerate_scan_devices = (uDEV_enumerate_scan_devices*)m_libraryLoader->resolve("udev_enumerate_scan_devices");
97  m_uDev.enumerate_get_list_entry = (uDEV_enumerate_get_list_entry*)m_libraryLoader->resolve("udev_enumerate_get_list_entry");
98  m_uDev.enumerate_unref = (uDEV_enumerate_unref*)m_libraryLoader->resolve("udev_enumerate_unref");
99  m_uDev.list_entry_get_next = (uDEV_list_entry_get_next*)m_libraryLoader->resolve("udev_list_entry_get_next");
100  m_uDev.list_entry_get_name = (uDEV_list_entry_get_name*)m_libraryLoader->resolve("udev_list_entry_get_name");
101  m_uDev.device_new_from_syspath = (uDEV_device_new_from_syspath*)m_libraryLoader->resolve("udev_device_new_from_syspath");
102  m_uDev.device_get_parent = (uDEV_device_get_parent*)m_libraryLoader->resolve("udev_device_get_parent");
103  m_uDev.device_get_devnode = (uDEV_device_get_devnode*)m_libraryLoader->resolve("udev_device_get_devnode");
104  m_uDev.device_get_parent_with_subsystem_devtype = (uDEV_device_get_parent_with_subsystem_devtype*)m_libraryLoader->resolve("udev_device_get_parent_with_subsystem_devtype");
105  m_uDev.device_get_sysattr_value = (uDEV_device_get_sysattr_value*)m_libraryLoader->resolve("udev_device_get_sysattr_value");
106  }
107 }
108 
117 udev* Udev::unew(void)
118 {
119  if (m_uDev.unew)
120  return m_uDev.unew();
121  else
122  return NULL;
123 }
124 
131 udev* Udev::unref(struct udev* udev)
132 {
133  if (m_uDev.unref)
134  return m_uDev.unref(udev);
135  else
136  return NULL;
137 }
138 
146 udev_device* Udev::device_unref(struct udev_device* udev_device)
147 {
148  if (m_uDev.device_unref)
149  return m_uDev.device_unref(udev_device);
150  else
151  return NULL;
152 }
153 
159 udev_enumerate* Udev::enumerate_new(struct udev* udev)
160 {
161  if (m_uDev.enumerate_new)
162  return m_uDev.enumerate_new(udev);
163  else
164  return NULL;
165 }
166 
172 int Udev::enumerate_add_match_subsystem(struct udev_enumerate* udev_enumerate, const char* subsystem)
173 {
174  if (m_uDev.enumerate_add_match_subsystem)
175  return m_uDev.enumerate_add_match_subsystem(udev_enumerate, subsystem);
176  else
177  return -1;
178 }
179 
184 int Udev::enumerate_scan_devices(struct udev_enumerate* udev_enumerate)
185 {
186  if (m_uDev.enumerate_scan_devices)
187  return m_uDev.enumerate_scan_devices(udev_enumerate);
188  else
189  return -1;
190 }
191 
197 udev_list_entry* Udev::list_entry_get_next(struct udev_list_entry* list_entry)
198 {
199  if (m_uDev.list_entry_get_next)
200  return m_uDev.list_entry_get_next(list_entry);
201  else
202  return NULL;
203 }
204 
209 udev_list_entry* Udev::enumerate_get_list_entry(struct udev_enumerate* udev_enumerate)
210 {
211  if (m_uDev.enumerate_get_list_entry)
212  return m_uDev.enumerate_get_list_entry(udev_enumerate);
213  else
214  return NULL;
215 }
216 
225 udev_enumerate* Udev::enumerate_unref(struct udev_enumerate* udev_enumerate)
226 {
227  if (m_uDev.enumerate_unref)
228  return m_uDev.enumerate_unref(udev_enumerate);
229  else
230  return NULL;
231 }
232 
237 const char* Udev::list_entry_get_name(struct udev_list_entry* list_entry)
238 {
239  if (m_uDev.list_entry_get_name)
240  return m_uDev.list_entry_get_name(list_entry);
241  else
242  return "";
243 }
244 
253 udev_device* Udev::device_new_from_syspath(struct udev* udev, const char* syspath)
254 {
255  if (m_uDev.device_new_from_syspath)
256  return m_uDev.device_new_from_syspath(udev, syspath);
257  else
258  return NULL;
259 }
260 
271 udev_device* Udev::device_get_parent(struct udev_device* udev_device)
272 {
273  if (m_uDev.device_get_parent)
274  return m_uDev.device_get_parent(udev_device);
275  else
276  return NULL;
277 }
278 
286 const char* Udev::device_get_devnode(struct udev_device* udev_device)
287 {
288  if (m_uDev.device_get_devnode)
289  return m_uDev.device_get_devnode(udev_device);
290  else
291  return "";
292 }
293 
307 udev_device* Udev::device_get_parent_with_subsystem_devtype(struct udev_device* udev_device, const char* subsystem, const char* devtype)
308 {
309  if (m_uDev.device_get_parent_with_subsystem_devtype)
310  return m_uDev.device_get_parent_with_subsystem_devtype(udev_device, subsystem, devtype);
311  else
312  return NULL;
313 }
314 
324 const char* Udev::device_get_sysattr_value(struct udev_device* udev_device, const char* sysattr)
325 {
326  if (m_uDev.device_get_sysattr_value)
327  return m_uDev.device_get_sysattr_value(udev_device, sysattr);
328  else
329  return "";
330 }
uDEV_list_entry_get_name
const typedef char * uDEV_list_entry_get_name(struct udev_list_entry *list_entry)
uDEV_list_entry_get_next
struct udev_list_entry * uDEV_list_entry_get_next(struct udev_list_entry *list_entry)
Definition: udev.h:83
xslibraryloader.h
uDEV_device_get_parent_with_subsystem_devtype
struct udev_device * uDEV_device_get_parent_with_subsystem_devtype(struct udev_device *udev_device, const char *subsystem, const char *devtype)
Definition: udev.h:88
uDEV_device_get_sysattr_value
const typedef char * uDEV_device_get_sysattr_value(struct udev_device *udev_device, const char *sysattr)
uDEV_enumerate_scan_devices
int uDEV_enumerate_scan_devices(struct udev_enumerate *udev_enumerate)
Definition: udev.h:80
udev.h
uDEV_device_new_from_syspath
struct udev_device * uDEV_device_new_from_syspath(struct udev *udev, const char *syspath)
Definition: udev.h:85
uDEV_device_unref
struct udev_device * uDEV_device_unref(struct udev_device *udev_device)
Definition: udev.h:77
uDEV_enumerate_get_list_entry
struct udev_list_entry * uDEV_enumerate_get_list_entry(struct udev_enumerate *udev_enumerate)
Definition: udev.h:81
XsLibraryLoader
struct XsLibraryLoader XsLibraryLoader
Definition: xslibraryloader.h:78
uDEV_enumerate_new
struct udev_enumerate * uDEV_enumerate_new(struct udev *udev)
Definition: udev.h:78
uDEV_enumerate_add_match_subsystem
int uDEV_enumerate_add_match_subsystem(struct udev_enumerate *udev_enumerate, const char *subsystem)
Definition: udev.h:79
uDEV_enumerate_unref
struct udev_enumerate * uDEV_enumerate_unref(struct udev_enumerate *udev_enumerate)
Definition: udev.h:82
uDEV_unref
struct udev * uDEV_unref(struct udev *udev)
Definition: udev.h:76
uDEV_device_get_parent
struct udev_device * uDEV_device_get_parent(struct udev_device *udev_device)
Definition: udev.h:86
uDEV_new
struct udev * uDEV_new(void)
Definition: udev.h:75
uDEV_device_get_devnode
const typedef char * uDEV_device_get_devnode(struct udev_device *udev_device)


xsens_mti_driver
Author(s):
autogenerated on Sun Sep 3 2023 02:43:20