Systemd/src/systemd/sd-hwdb.h
Lennart Poettering 04c0136989 sd-*.h: clean up exported (or to-be-exported) header files
Exported header files should not include internal headers. Fix that.

Exported header files should not use the bool type. So far we opted to
stick to C89 for exported headers, and hence use "int" for bools in
them. Continue to do so.

Exported header files should have #include lines for everything they use
including inttypes.h and sys/types.h, so that they may be included in
any order.

Exported header files should have C++ guards, hence add them.

Exported header files should not use gcc extensions like #pragma once,
get rid of it.
2015-10-24 23:42:56 +02:00

50 lines
1.6 KiB
C

/*-*- 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);
/* the inverse condition avoids ambiguity of dangling 'else' after the macro */
#define SD_HWDB_FOREACH_PROPERTY(hwdb, modalias, key, value) \
if (sd_hwdb_seek(hwdb, modalias) < 0) { } \
else while (sd_hwdb_enumerate(hwdb, &(key), &(value)) > 0)
_SD_END_DECLARATIONS;
#endif