On Fri, 2012-04-27 at 13:07 +1000, Peter Hutterer wrote:
> 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>

Minor style comment below

Reviewed-By: Bastien Nocera <had...@hadess.net>

> ---
> Changes to v3
> - use G_OPTION_ARG_FILENAME
> - returned path isn't const, it needs to be freed
> 
>  tools/Makefile.am          |    1 +
>  tools/list-local-devices.c |   33 ++++++++++++++++++++++++++++++++-
>  2 files changed, 33 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..911407f 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,30 @@ 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();

I'd put braces in for both branches of the conditional, otherwise it
looks weird.

> -     db = libwacom_database_new_for_path(TOPSRCDIR"/data");
>       if (!db) {
>               fprintf(stderr, "Failed to initialize device database\n");
>               return 1;



------------------------------------------------------------------------------
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

Reply via email to