Let the caller specify the database path (for local testing), otherwise use the system-installed database.
Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net> --- Changes to v1: - drop the original patch, replace with a commandline option for local testing tools/Makefile.am | 1 + tools/list-local-devices.c | 32 +++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/tools/Makefile.am b/tools/Makefile.am index 2238cec..b8b0aef 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -10,4 +10,5 @@ list_devices_LDADD=$(top_builddir)/libwacom/libwacom.la bin_PROGRAMS = libwacom-list-local-devices libwacom_list_local_devices_SOURCES = list-local-devices.c libwacom_list_local_devices_LDADD=$(top_builddir)/libwacom/libwacom.la +libwacom_list_local_devices_CFLAGS=$(GLIB_CFLAGS) diff --git a/tools/list-local-devices.c b/tools/list-local-devices.c index 3dbba3d..ce7340a 100644 --- a/tools/list-local-devices.c +++ b/tools/list-local-devices.c @@ -33,8 +33,17 @@ #include <string.h> #include <assert.h> #include <dirent.h> +#include <glib/gi18n.h> +#include <glib.h> #include "libwacom.h" +static const char *database_path; + +static GOptionEntry opts[] = { + {"database", 0, 0, G_OPTION_ARG_STRING, &database_path, N_("Path to device database"), NULL }, + {NULL} +}; + static int event_devices_only(const struct dirent *dir) { return strncmp("event", dir->d_name, 5) == 0; } @@ -45,8 +54,29 @@ int main(int argc, char **argv) WacomDevice *dev; int i; struct dirent **namelist = NULL; + GOptionContext *context; + GError *error; + + context = g_option_context_new (NULL); + + g_option_context_add_main_entries (context, opts, NULL); + error = NULL; + + if (!g_option_context_parse (context, &argc, &argv, &error)) { + if (error != NULL) { + fprintf (stderr, "%s\n", error->message); + g_error_free (error); + } + return EXIT_FAILURE; + } + + g_option_context_free (context); + + if (database_path) + db = libwacom_database_new_for_path(database_path); + else + db = libwacom_database_new(); - db = libwacom_database_new_for_path(TOPSRCDIR"/data"); if (!db) { fprintf(stderr, "Failed to initialize device database\n"); return 1; -- 1.7.10 ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel