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