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