summaryrefslogtreecommitdiff
path: root/src/systemd/sd-hwdb.h
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-12-03 17:02:34 +0100
committerTom Gundersen <teg@jklm.no>2014-12-11 13:54:35 +0100
commit23fbe14f503c1e98292efc4ba1238adb7dc38d80 (patch)
tree51f48cee1d345ad9c2d04aff622f99be8d362998 /src/systemd/sd-hwdb.h
parent94e15fdc4d9d96fa6607bfb4eaaea164a3aec417 (diff)
libsystemd: add sd-hwdb library
This is libudev-hwdb, but decoupled from libudev and in the libsystemd style. The core code is unchanged, apart from the following minor changes: - hwdb.bin located in /**/systemd/hwdb/ take preference over the ones located in /**/udev/ - properties are stored internally in an OrderedHashmap, rather than a linked list. - a new API call allows individual properties to be queried directly, rather than iterating over them all - the iteration over properties have been moved inside the library, rather than exposing a list directly - the unused 'flags' parameter was dropped
Diffstat (limited to 'src/systemd/sd-hwdb.h')
-rw-r--r--src/systemd/sd-hwdb.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/systemd/sd-hwdb.h b/src/systemd/sd-hwdb.h
new file mode 100644
index 000000000..fae9b9fd4
--- /dev/null
+++ b/src/systemd/sd-hwdb.h
@@ -0,0 +1,46 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+#ifndef foosdhwdbhfoo
+#define foosdhwdbhfoo
+
+/***
+ This file is part of systemd.
+
+ Copyright 2008-2012 Kay Sievers <kay@vrfy.org>
+ Copyright 2014 Tom Gundersen <teg@jklm.no>
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include "_sd-common.h"
+
+_SD_BEGIN_DECLARATIONS;
+
+typedef struct sd_hwdb sd_hwdb;
+
+sd_hwdb *sd_hwdb_ref(sd_hwdb *hwdb);
+sd_hwdb *sd_hwdb_unref(sd_hwdb *hwdb);
+
+int sd_hwdb_new(sd_hwdb **ret);
+
+int sd_hwdb_get(sd_hwdb *hwdb, const char *modalias, const char *key, const char **value);
+
+int sd_hwdb_seek(sd_hwdb *hwdb, const char *modalias);
+int sd_hwdb_enumerate(sd_hwdb *hwdb, const char **key, const char **value);
+
+#define FOREACH_HWDB_PROPERTY(hwdb, modalias, key, value) \
+ if (sd_hwdb_seek(hwdb, modalias) >= 0) \
+ while (sd_hwdb_enumerate(hwdb, &(key), &(value)) > 0)
+
+#endif