]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/systemd/sd-hwdb.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
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.
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.
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/>.
20 #include "_sd-common.h"
22 _SD_BEGIN_DECLARATIONS
;
24 typedef struct sd_hwdb sd_hwdb
;
26 sd_hwdb
*sd_hwdb_ref(sd_hwdb
*hwdb
);
27 sd_hwdb
*sd_hwdb_unref(sd_hwdb
*hwdb
);
29 int sd_hwdb_new(sd_hwdb
**ret
);
31 int sd_hwdb_get(sd_hwdb
*hwdb
, const char *modalias
, const char *key
, const char **value
);
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
);
36 /* the inverse condition avoids ambiguity of dangling 'else' after the macro */
37 #define SD_HWDB_FOREACH_PROPERTY(hwdb, modalias, key, value) \
38 if (sd_hwdb_seek(hwdb, modalias) < 0) { } \
39 else while (sd_hwdb_enumerate(hwdb, &(key), &(value)) > 0)
41 _SD_DEFINE_POINTER_CLEANUP_FUNC(sd_hwdb
, sd_hwdb_unref
);