Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions libwacom/libwacom-database.c
Original file line number Diff line number Diff line change
Expand Up @@ -1132,11 +1132,10 @@ stylus_compare(WacomStylusId *a, WacomStylusId *b)
}

static WacomDeviceDatabase *
database_new_for_paths (size_t npaths, const char **datadirs)
database_new_for_paths (char * const *datadirs)
{
WacomDeviceDatabase *db;
size_t n;
const char **datadir;
char * const *datadir;

db = g_new0 (WacomDeviceDatabase, 1);
db->device_ht = g_hash_table_new_full (g_str_hash,
Expand All @@ -1148,12 +1147,12 @@ database_new_for_paths (size_t npaths, const char **datadirs)
(GDestroyNotify) g_free,
(GDestroyNotify) stylus_destroy);

for (datadir = datadirs, n = npaths; n--; datadir++) {
for (datadir = datadirs; *datadir; datadir++) {
if (!load_stylus_files(db, *datadir))
goto error;
}

for (datadir = datadirs, n = npaths; n--; datadir++) {
for (datadir = datadirs; *datadir; datadir++) {
if (!load_tablet_files(db, *datadir))
goto error;
}
Expand All @@ -1175,18 +1174,27 @@ database_new_for_paths (size_t npaths, const char **datadirs)
LIBWACOM_EXPORT WacomDeviceDatabase *
libwacom_database_new_for_path (const char *datadir)
{
return database_new_for_paths(1, &datadir);
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,
};

return database_new_for_paths (2, datadir);
return database_new_for_paths(datadir);
}

LIBWACOM_EXPORT void
Expand Down
10 changes: 8 additions & 2 deletions libwacom/libwacom.h
Original file line number Diff line number Diff line change
Expand Up @@ -354,10 +354,16 @@ WacomDeviceDatabase* libwacom_database_new(void);

/**
* Loads the Tablet and Stylus databases, to be used
* in libwacom_new_*() functions, from the prefix
* path passes. This is only useful for diagnostics
* in libwacom_new_*() functions, from the datadir
* given in the argument. This is only useful for diagnostics
* applications.
*
* The datadir must contain the libwacom .tablet files and optionally
* 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