summaryrefslogtreecommitdiff
path: root/tools/list-local-devices.c
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2012-04-23 16:18:55 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2012-04-30 07:55:40 +1000
commit7983835867eae35f65b7e58429659af4ffc136a9 (patch)
tree4ed62b6ceaf6590967f70518c5a91a62c1ca2339 /tools/list-local-devices.c
parent06da689112bd26d6125c28f762d8d1642b3e0d00 (diff)
downloadlibwacom-7983835867eae35f65b7e58429659af4ffc136a9.tar.gz
tools: Add --database option to list-local-devices
Let the caller specify the database path (for local testing), otherwise use the system-installed database. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Bastien Nocera <hadess@hadess.net>
Diffstat (limited to 'tools/list-local-devices.c')
-rw-r--r--tools/list-local-devices.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/tools/list-local-devices.c b/tools/list-local-devices.c
index 3dbba3d..17cd28c 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 char *database_path;
+
+static GOptionEntry opts[] = {
+ {"database", 0, 0, G_OPTION_ARG_FILENAME, &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,31 @@ 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);
+ g_free (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;