Skip to content

Commit

Permalink
database: allow for multiple entries in a database path
Browse files Browse the repository at this point in the history
Split the given database path by colon, same as PATH behavior, to allow
callers to pass multiple database paths.
  • Loading branch information
whot committed Oct 23, 2024
1 parent b8901bd commit 78f2b9e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
20 changes: 12 additions & 8 deletions libwacom/libwacom-database.c
Original file line number Diff line number Diff line change
Expand Up @@ -1132,10 +1132,10 @@ stylus_compare(WacomStylusId *a, WacomStylusId *b)
}

static WacomDeviceDatabase *
database_new_for_paths (const char **datadirs)
database_new_for_paths (char * const *datadirs)
{
WacomDeviceDatabase *db;
const char **datadir;
char * const *datadir;

db = g_new0 (WacomDeviceDatabase, 1);
db->device_ht = g_hash_table_new_full (g_str_hash,
Expand Down Expand Up @@ -1174,17 +1174,21 @@ database_new_for_paths (const char **datadirs)
LIBWACOM_EXPORT WacomDeviceDatabase *
libwacom_database_new_for_path (const char *datadir)
{
const char *datadirs[] = {
datadir,
NULL,
};
return database_new_for_paths(datadirs);
WacomDeviceDatabase *db;
char **paths;

paths = g_strsplit(datadir, ":", 0);
db = database_new_for_paths(paths);

g_strfreev(paths);

return db;
}

LIBWACOM_EXPORT WacomDeviceDatabase *
libwacom_database_new (void)
{
const char *datadir[] = {
char *datadir[] = {
ETCDIR,
DATADIR,
NULL,
Expand Down
2 changes: 2 additions & 0 deletions libwacom/libwacom.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,8 @@ WacomDeviceDatabase* libwacom_database_new(void);
* a layouts/ subdirectory for the svg files if any of the .tablet
* files references an svg.
*
* datadir may be a colon-separated list of directories.
*
* @return A new database or NULL on error.
*
* @ingroup context
Expand Down

0 comments on commit 78f2b9e

Please sign in to comment.