]>
Commit | Line | Data |
---|---|---|
db9ecf05 | 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
23fbe14f TG |
2 | #ifndef foosdhwdbhfoo |
3 | #define foosdhwdbhfoo | |
4 | ||
5 | /*** | |
23fbe14f TG |
6 | systemd is free software; you can redistribute it and/or modify it |
7 | under the terms of the GNU Lesser General Public License as published by | |
8 | the Free Software Foundation; either version 2.1 of the License, or | |
9 | (at your option) any later version. | |
10 | ||
11 | systemd is distributed in the hope that it will be useful, but | |
12 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | Lesser General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU Lesser General Public License | |
17 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
18 | ***/ | |
19 | ||
20 | #include "_sd-common.h" | |
21 | ||
22 | _SD_BEGIN_DECLARATIONS; | |
23 | ||
24 | typedef struct sd_hwdb sd_hwdb; | |
25 | ||
26 | sd_hwdb *sd_hwdb_ref(sd_hwdb *hwdb); | |
27 | sd_hwdb *sd_hwdb_unref(sd_hwdb *hwdb); | |
28 | ||
29 | int sd_hwdb_new(sd_hwdb **ret); | |
30 | ||
31 | int sd_hwdb_get(sd_hwdb *hwdb, const char *modalias, const char *key, const char **value); | |
32 | ||
33 | int sd_hwdb_seek(sd_hwdb *hwdb, const char *modalias); | |
34 | int sd_hwdb_enumerate(sd_hwdb *hwdb, const char **key, const char **value); | |
35 | ||
04c01369 | 36 | /* the inverse condition avoids ambiguity of dangling 'else' after the macro */ |
0b931571 | 37 | #define SD_HWDB_FOREACH_PROPERTY(hwdb, modalias, key, value) \ |
bff686e2 DH |
38 | if (sd_hwdb_seek(hwdb, modalias) < 0) { } \ |
39 | else while (sd_hwdb_enumerate(hwdb, &(key), &(value)) > 0) | |
23fbe14f | 40 | |
4afd3348 LP |
41 | _SD_DEFINE_POINTER_CLEANUP_FUNC(sd_hwdb, sd_hwdb_unref); |
42 | ||
04c01369 LP |
43 | _SD_END_DECLARATIONS; |
44 | ||
23fbe14f | 45 | #endif |