File: udev.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (127 lines) | stat: -rw-r--r-- 5,401 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef DEVICE_UDEV_LINUX_UDEV_H_
#define DEVICE_UDEV_LINUX_UDEV_H_

#include <stdarg.h>
#include <sys/types.h>
#include <sys/stat.h>

#include <string>
#include "base/component_export.h"

#if !defined(USE_UDEV)
#error "USE_UDEV not defined"
#endif

// Adapted from libudev.h.
#define udev_list_entry_foreach(list_entry, first_entry) \
  for (list_entry = first_entry; list_entry != NULL;     \
       list_entry = ::device::udev_list_entry_get_next(list_entry))

// Forward declarations of opaque structs.
struct udev;
struct udev_device;
struct udev_enumerate;
struct udev_list_entry;
struct udev_monitor;

namespace device {

COMPONENT_EXPORT(DEVICE_UDEV_LINUX)
const char* udev_device_get_action(udev_device* udev_device);
COMPONENT_EXPORT(DEVICE_UDEV_LINUX)
const char* udev_device_get_devnode(udev_device* udev_device);
COMPONENT_EXPORT(DEVICE_UDEV_LINUX)
const char* udev_device_get_devtype(udev_device* udev_device);
COMPONENT_EXPORT(DEVICE_UDEV_LINUX)
udev_device* udev_device_get_parent(udev_device* udev_device);
COMPONENT_EXPORT(DEVICE_UDEV_LINUX)
udev_device* udev_device_get_parent_with_subsystem_devtype(
    udev_device* udev_device,
    const char* subsystem,
    const char* devtype);
COMPONENT_EXPORT(DEVICE_UDEV_LINUX)
udev_list_entry* udev_device_get_properties_list_entry(
    struct udev_device* udev_device);
COMPONENT_EXPORT(DEVICE_UDEV_LINUX)
const char* udev_device_get_property_value(udev_device* udev_device,
                                           const char* key);
COMPONENT_EXPORT(DEVICE_UDEV_LINUX)
const char* udev_device_get_subsystem(udev_device* udev_device);
COMPONENT_EXPORT(DEVICE_UDEV_LINUX)
const char* udev_device_get_sysattr_value(udev_device* udev_device,
                                          const char* sysattr);
COMPONENT_EXPORT(DEVICE_UDEV_LINUX)
const char* udev_device_get_sysname(udev_device* udev_device);
COMPONENT_EXPORT(DEVICE_UDEV_LINUX)
const char* udev_device_get_syspath(udev_device* udev_device);
COMPONENT_EXPORT(DEVICE_UDEV_LINUX)
udev_device* udev_device_new_from_devnum(udev* udev, char type, dev_t devnum);
COMPONENT_EXPORT(DEVICE_UDEV_LINUX)
udev_device* udev_device_new_from_subsystem_sysname(udev* udev,
                                                    const char* subsystem,
                                                    const char* sysname);
COMPONENT_EXPORT(DEVICE_UDEV_LINUX)
udev_device* udev_device_new_from_syspath(udev* udev, const char* syspath);
COMPONENT_EXPORT(DEVICE_UDEV_LINUX)
void udev_device_unref(udev_device* udev_device);
COMPONENT_EXPORT(DEVICE_UDEV_LINUX)
int udev_enumerate_add_match_subsystem(udev_enumerate* udev_enumerate,
                                       const char* subsystem);
COMPONENT_EXPORT(DEVICE_UDEV_LINUX)
udev_list_entry* udev_enumerate_get_list_entry(udev_enumerate* udev_enumerate);
COMPONENT_EXPORT(DEVICE_UDEV_LINUX)
udev_enumerate* udev_enumerate_new(udev* udev);
COMPONENT_EXPORT(DEVICE_UDEV_LINUX)
int udev_enumerate_scan_devices(udev_enumerate* udev_enumerate);
COMPONENT_EXPORT(DEVICE_UDEV_LINUX)
void udev_enumerate_unref(udev_enumerate* udev_enumerate);
COMPONENT_EXPORT(DEVICE_UDEV_LINUX)
udev_list_entry* udev_list_entry_get_next(udev_list_entry* list_entry);
COMPONENT_EXPORT(DEVICE_UDEV_LINUX)
const char* udev_list_entry_get_name(udev_list_entry* list_entry);
COMPONENT_EXPORT(DEVICE_UDEV_LINUX)
int udev_monitor_enable_receiving(udev_monitor* udev_monitor);
COMPONENT_EXPORT(DEVICE_UDEV_LINUX)
int udev_monitor_filter_add_match_subsystem_devtype(udev_monitor* udev_monitor,
                                                    const char* subsystem,
                                                    const char* devtype);
COMPONENT_EXPORT(DEVICE_UDEV_LINUX)
int udev_monitor_get_fd(udev_monitor* udev_monitor);
COMPONENT_EXPORT(DEVICE_UDEV_LINUX)
udev_monitor* udev_monitor_new_from_netlink(udev* udev, const char* name);
COMPONENT_EXPORT(DEVICE_UDEV_LINUX)
udev_device* udev_monitor_receive_device(udev_monitor* udev_monitor);
COMPONENT_EXPORT(DEVICE_UDEV_LINUX)
void udev_monitor_unref(udev_monitor* udev_monitor);
COMPONENT_EXPORT(DEVICE_UDEV_LINUX) udev* udev_new();
COMPONENT_EXPORT(DEVICE_UDEV_LINUX) void udev_unref(udev* udev);

// Calls udev_device_get_property_value() and replaces missing values with
// the empty string.
COMPONENT_EXPORT(DEVICE_UDEV_LINUX)
std::string UdevDeviceGetPropertyValue(udev_device* udev_device,
                                       const char* key);

// Calls udev_device_get_sysattr_value() and replaces missing values with
// the empty string.
COMPONENT_EXPORT(DEVICE_UDEV_LINUX)
std::string UdevDeviceGetSysattrValue(udev_device* udev_device,
                                      const char* key);

// Walks up the chain of parent devices calling udev_device_get_sysattr_value()
// until a value is found. If no value is found, an empty string is returned.
COMPONENT_EXPORT(DEVICE_UDEV_LINUX)
std::string UdevDeviceRecursiveGetSysattrValue(udev_device* udev_device,
                                               const char* key);

// Decodes udev-encoded string. Useful for decoding "*_ENC" udev properties.
COMPONENT_EXPORT(DEVICE_UDEV_LINUX)
std::string UdevDecodeString(const std::string& encoded);

}  // namespace device

#endif  // DEVICE_UDEV_LINUX_UDEV_H_