OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef DEVICE_UDEV_LINUX_UDEV_LOADER_H_ |
| 6 #define DEVICE_UDEV_LINUX_UDEV_LOADER_H_ |
| 7 |
| 8 #include <stdarg.h> |
| 9 #include <sys/types.h> |
| 10 #include <sys/stat.h> |
| 11 |
| 12 #if !defined(USE_UDEV) |
| 13 #error "USE_UDEV not defined" |
| 14 #endif |
| 15 |
| 16 struct udev; |
| 17 struct udev_device; |
| 18 struct udev_enumerate; |
| 19 struct udev_list_entry; |
| 20 struct udev_monitor; |
| 21 |
| 22 namespace device { |
| 23 |
| 24 // Interface to libudev. Accessed through the static Get() function, which |
| 25 // will try to load libudev1 first and then libudev0 on first use. If neither |
| 26 // libraries load successfully, the program will fail with a crash. |
| 27 // |
| 28 // All the methods have the same signatures as libudev's functions. e.g. |
| 29 // udev_monitor_get_fd(mon) simply becomes device::udev_monitor_get_fd(mon). |
| 30 class UdevLoader { |
| 31 public: |
| 32 static UdevLoader* Get(); |
| 33 |
| 34 virtual ~UdevLoader(); |
| 35 |
| 36 virtual bool Init() = 0; |
| 37 |
| 38 virtual const char* udev_device_get_action(udev_device* udev_device) = 0; |
| 39 virtual const char* udev_device_get_devnode(udev_device* udev_device) = 0; |
| 40 virtual udev_device* udev_device_get_parent(udev_device* udev_device) = 0; |
| 41 virtual udev_device* udev_device_get_parent_with_subsystem_devtype( |
| 42 udev_device* udev_device, |
| 43 const char* subsystem, |
| 44 const char* devtype) = 0; |
| 45 virtual const char* udev_device_get_property_value(udev_device* udev_device, |
| 46 const char* key) = 0; |
| 47 virtual const char* udev_device_get_subsystem(udev_device* udev_device) = 0; |
| 48 virtual const char* udev_device_get_sysattr_value(udev_device* udev_device, |
| 49 const char* sysattr) = 0; |
| 50 virtual const char* udev_device_get_sysname(udev_device* udev_device) = 0; |
| 51 virtual const char* udev_device_get_syspath(udev_device* udev_device) = 0; |
| 52 virtual udev_device* udev_device_new_from_devnum(udev* udev, |
| 53 char type, |
| 54 dev_t devnum) = 0; |
| 55 virtual udev_device* udev_device_new_from_syspath(udev* udev, |
| 56 const char* syspath) = 0; |
| 57 virtual void udev_device_unref(udev_device* udev_device) = 0; |
| 58 virtual int udev_enumerate_add_match_subsystem(udev_enumerate* udev_enumerate, |
| 59 const char* subsystem) = 0; |
| 60 virtual udev_list_entry* udev_enumerate_get_list_entry( |
| 61 udev_enumerate* udev_enumerate) = 0; |
| 62 virtual udev_enumerate* udev_enumerate_new(udev* udev) = 0; |
| 63 virtual int udev_enumerate_scan_devices(udev_enumerate* udev_enumerate) = 0; |
| 64 virtual void udev_enumerate_unref(udev_enumerate* udev_enumerate) = 0; |
| 65 virtual udev_list_entry* udev_list_entry_get_next( |
| 66 udev_list_entry* list_entry) = 0; |
| 67 virtual const char* udev_list_entry_get_name(udev_list_entry* list_entry) = 0; |
| 68 virtual int udev_monitor_enable_receiving(udev_monitor* udev_monitor) = 0; |
| 69 virtual int udev_monitor_filter_add_match_subsystem_devtype( |
| 70 udev_monitor* udev_monitor, |
| 71 const char* subsystem, |
| 72 const char* devtype) = 0; |
| 73 virtual int udev_monitor_get_fd(udev_monitor* udev_monitor) = 0; |
| 74 virtual udev_monitor* udev_monitor_new_from_netlink(udev* udev, |
| 75 const char* name) = 0; |
| 76 virtual udev_device* udev_monitor_receive_device( |
| 77 udev_monitor* udev_monitor) = 0; |
| 78 virtual void udev_monitor_unref(udev_monitor* udev_monitor) = 0; |
| 79 virtual udev* udev_new() = 0; |
| 80 virtual void udev_set_log_fn( |
| 81 struct udev* udev, |
| 82 void (*log_fn)(struct udev* udev, int priority, |
| 83 const char* file, int line, |
| 84 const char* fn, const char* format, va_list args)) = 0; |
| 85 virtual void udev_set_log_priority(struct udev* udev, int priority) = 0; |
| 86 virtual void udev_unref(udev* udev) = 0; |
| 87 }; |
| 88 |
| 89 } // namespace device |
| 90 |
| 91 #endif // DEVICE_UDEV_LINUX_UDEV_LOADER_H_ |
OLD | NEW |