database: extract common method to handle machine id and architecture

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/425>
This commit is contained in:
Igor V. Kovalenko 2020-11-29 11:21:29 +03:00 committed by PulseAudio Marge Bot
parent 0efae0488c
commit 0ac6b16787
12 changed files with 154 additions and 65 deletions

View file

@ -222,14 +222,21 @@ static int fill_data(simple_data *db, FILE *f) {
return pa_hashmap_size(db->map);
}
pa_database* pa_database_open(const char *fn, bool for_write) {
const char* pa_database_get_arch_suffix(void) {
/* Simple database binary file format is CPU dependent. */
return CANONICAL_HOST;
}
const char* pa_database_get_filename_suffix(void) {
return ".simple";
}
pa_database* pa_database_open_internal(const char *path, bool for_write) {
FILE *f;
char *path;
simple_data *db;
pa_assert(fn);
pa_assert(path);
path = pa_sprintf_malloc("%s."CANONICAL_HOST".simple", fn);
errno = 0;
f = pa_fopen_cloexec(path, "r");
@ -251,8 +258,6 @@ pa_database* pa_database_open(const char *fn, bool for_write) {
db = NULL;
}
pa_xfree(path);
return (pa_database*) db;
}