pulseaudio/src/pulsecore/database.h
Igor V. Kovalenko ae9d0cf307 database: use existing database matching same architecture prefix
State database binary file format may depend on system architecture,
for instance gdbm binary format depends on architecture word size,
making x86 and x64 gdbm files incompatible.

If this is the case, it is handled by adding system architecture name to
database file name using automatically configured CANONICAL_HOST string.
Meson build define CANONICAL_HOST to be system architecture name, while
autotools build extends this with vendor and and operating system components.

Switch autotools build to use host_cpu for CANONICAL_HOST to match Meson
configuration. For backwards compatibility always use existing database file
matching CANONICAL_HOST prefix if it exists.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/425>
2021-01-07 23:27:16 +00:00

69 lines
2.7 KiB
C

#ifndef foopulsecoredatabasehfoo
#define foopulsecoredatabasehfoo
/***
This file is part of PulseAudio.
Copyright 2009 Lennart Poettering
PulseAudio 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.
PulseAudio 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 PulseAudio; if not, see <http://www.gnu.org/licenses/>.
***/
#include <sys/types.h>
#include <pulsecore/macro.h>
/* A little abstraction over simple databases, such as gdbm, tdb, and
* so on. We only make minimal assumptions about the supported
* backend: it does not need to support locking, it does not have to
* be arch independent. */
typedef struct pa_database pa_database;
typedef struct pa_datum {
void *data;
size_t size;
} pa_datum;
void pa_datum_free(pa_datum *d);
/* Database implementation; returns non-empty system architecture name string if database file format depends on system architecture, or NULL otherwise. */
const char* pa_database_get_arch_suffix(void);
/* Database implementation; returns non-empty database filename extension string */
const char* pa_database_get_filename_suffix(void);
/* This will attempt opening database file matching compiled CANONICAL_HOST implementation architecture name prefix,
* or new database file will be created and opened with implementation architecture name suffix if required.
* If prependmid is true, file name is augmented with machine id prefix. */
pa_database* pa_database_open(const char *path, const char *fn, bool prependmid, bool for_write);
/* Database implementation; opens specified database file using provided path. */
pa_database* pa_database_open_internal(const char *path, bool for_write);
void pa_database_close(pa_database *db);
pa_datum* pa_database_get(pa_database *db, const pa_datum *key, pa_datum* data);
int pa_database_set(pa_database *db, const pa_datum *key, const pa_datum* data, bool overwrite);
int pa_database_unset(pa_database *db, const pa_datum *key);
int pa_database_clear(pa_database *db);
signed pa_database_size(pa_database *db);
pa_datum* pa_database_first(pa_database *db, pa_datum *key, pa_datum *data /* may be NULL */);
pa_datum* pa_database_next(pa_database *db, const pa_datum *key, pa_datum *next, pa_datum *data /* may be NULL */);
int pa_database_sync(pa_database *db);
#endif