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