On Wed, Mar 30, 2011 at 01:54:43PM -0700, Jason Gerecke wrote:
> When setting an XInternAtom property, 'prop_extra' listed
> the number of extra properties beyond the first that needed
> to be set. For instance WACOM_PROP_TABLET_AREA had a total
> of 4 properties, so prop_extra=3.
> 
> To provide better argument validation though, we change this
> to 'arg_count' and list the total number of arguments
> expected. This doesn't really do anything for normal properties
> (since arg_count = prop_extra + 1), but does let us check
> for the proper number of arguments in odd cases (e.g.
> ResetArea takes 0 arguments).
> 
> Signed-off-by: Jason Gerecke <killert...@gmail.com>
> ---
>  tools/xsetwacom.c |   40 +++++++++++++++++++++++++++++++++-------
>  1 files changed, 33 insertions(+), 7 deletions(-)
> 
> diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c
> index 4194781..ae35996 100644
> --- a/tools/xsetwacom.c
> +++ b/tools/xsetwacom.c
> @@ -86,7 +86,7 @@ typedef struct _param
>       const char *prop_name;  /* property name */
>       const int prop_format;  /* property format */
>       const int prop_offset;  /* offset (index) into the property values */
> -     const int prop_extra;   /* extra number of items after first one */
> +     const int arg_count;   /* extra number of items after first one */

I've updated the comment here. merged otherwise.

Cheers,
  Peter


>       const unsigned int prop_flags;
>       void (*set_func)(Display *dpy, XDevice *dev, struct _param *param, int 
> argc, char **argv); /* handler function, if appropriate */
>       void (*get_func)(Display *dpy, XDevice *dev, struct _param *param, int 
> argc, char **argv); /* handler function for getting, if appropriate */
> @@ -120,12 +120,13 @@ static param_t parameters[] =
>               .prop_name = WACOM_PROP_TABLET_AREA,
>               .prop_format = 32,
>               .prop_offset = 0,
> -             .prop_extra = 3
> +             .arg_count = 4,
>       },
>       {
>               .name = "Button",
>               .desc = "X11 event to which the given button should be mapped. 
> ",
>               .prop_name = WACOM_PROP_BUTTON_ACTIONS,
> +             .arg_count = 1,
>               .set_func = map_actions,
>               .get_func = get_map,
>       },
> @@ -136,6 +137,7 @@ static param_t parameters[] =
>               .prop_name = WACOM_PROP_DEBUGLEVELS,
>               .prop_format = 8,
>               .prop_offset = 0,
> +             .arg_count = 1,
>       },
>       {
>               .name = "TabletDebugLevel",
> @@ -145,6 +147,7 @@ static param_t parameters[] =
>               .prop_name = WACOM_PROP_DEBUGLEVELS,
>               .prop_format = 8,
>               .prop_offset = 1,
> +             .arg_count = 1,
>       },
>       {
>               .name = "Suppress",
> @@ -152,6 +155,7 @@ static param_t parameters[] =
>               .prop_name = WACOM_PROP_SAMPLE,
>               .prop_format = 32,
>               .prop_offset = 0,
> +             .arg_count = 1,
>       },
>       {
>               .name = "RawSample",
> @@ -160,6 +164,7 @@ static param_t parameters[] =
>               .prop_name = WACOM_PROP_SAMPLE,
>               .prop_format = 32,
>               .prop_offset = 1,
> +             .arg_count = 1,
>       },
>       {
>               .name = "PressureCurve",
> @@ -167,11 +172,12 @@ static param_t parameters[] =
>               .prop_name = WACOM_PROP_PRESSURECURVE,
>               .prop_format = 32,
>               .prop_offset = 0,
> -             .prop_extra = 3,
> +             .arg_count = 4,
>       },
>       {
>               .name = "Mode",
>               .desc = "Switches cursor movement mode (default is absolute). ",
> +             .arg_count = 1,
>               .set_func = set_mode,
>               .get_func = get_mode,
>       },
> @@ -183,6 +189,7 @@ static param_t parameters[] =
>               .prop_name = WACOM_PROP_HOVER,
>               .prop_format = 8,
>               .prop_offset = 0,
> +             .arg_count = 1,
>               .prop_flags = PROP_FLAG_BOOLEAN
>       },
>       {
> @@ -191,6 +198,7 @@ static param_t parameters[] =
>               .prop_name = WACOM_PROP_TOUCH,
>               .prop_format = 8,
>               .prop_offset = 0,
> +             .arg_count = 1,
>               .prop_flags = PROP_FLAG_BOOLEAN
>       },
>       {
> @@ -200,6 +208,7 @@ static param_t parameters[] =
>               .prop_name = WACOM_PROP_ENABLE_GESTURE,
>               .prop_format = 8,
>               .prop_offset = 0,
> +             .arg_count = 1,
>               .prop_flags = PROP_FLAG_BOOLEAN
>       },
>       {
> @@ -209,6 +218,7 @@ static param_t parameters[] =
>               .prop_name = WACOM_PROP_GESTURE_PARAMETERS,
>               .prop_format = 32,
>               .prop_offset = 0,
> +             .arg_count = 1,
>       },
>       {
>               .name = "ScrollDistance",
> @@ -217,6 +227,7 @@ static param_t parameters[] =
>               .prop_name = WACOM_PROP_GESTURE_PARAMETERS,
>               .prop_format = 32,
>               .prop_offset = 1,
> +             .arg_count = 1,
>       },
>       {
>               .name = "TapTime",
> @@ -225,6 +236,7 @@ static param_t parameters[] =
>               .prop_name = WACOM_PROP_GESTURE_PARAMETERS,
>               .prop_format = 32,
>               .prop_offset = 2,
> +             .arg_count = 1,
>       },
>       {
>               .name = "Capacity",
> @@ -233,6 +245,7 @@ static param_t parameters[] =
>               .prop_name = WACOM_PROP_CAPACITY,
>               .prop_format = 32,
>               .prop_offset = 0,
> +             .arg_count = 1,
>       },
>       {
>               .name = "CursorProximity",
> @@ -243,6 +256,7 @@ static param_t parameters[] =
>               .prop_name = WACOM_PROP_PROXIMITY_THRESHOLD,
>               .prop_format = 32,
>               .prop_offset = 0,
> +             .arg_count = 1,
>       },
>       {
>               .name = "Rotate",
> @@ -251,6 +265,7 @@ static param_t parameters[] =
>               .prop_name = WACOM_PROP_ROTATION,
>               .set_func = set_rotate,
>               .get_func = get_rotate,
> +             .arg_count = 1,
>       },
>       {
>               .name = "RelWheelUp",
> @@ -258,6 +273,7 @@ static param_t parameters[] =
>               .prop_name = WACOM_PROP_WHEELBUTTONS,
>               .prop_format = 8,
>               .prop_offset = 0,
> +             .arg_count = 0,
>               .set_func = map_actions,
>               .get_func = get_map,
>       },
> @@ -267,6 +283,7 @@ static param_t parameters[] =
>               .prop_name = WACOM_PROP_WHEELBUTTONS,
>               .prop_format = 8,
>               .prop_offset = 1,
> +             .arg_count = 0,
>               .set_func = map_actions,
>               .get_func = get_map,
>       },
> @@ -276,6 +293,7 @@ static param_t parameters[] =
>               .prop_name = WACOM_PROP_WHEELBUTTONS,
>               .prop_format = 8,
>               .prop_offset = 2,
> +             .arg_count = 0,
>               .set_func = map_actions,
>               .get_func = get_map,
>       },
> @@ -285,6 +303,7 @@ static param_t parameters[] =
>               .prop_name = WACOM_PROP_WHEELBUTTONS,
>               .prop_format = 8,
>               .prop_offset = 3,
> +             .arg_count = 0,
>               .set_func = map_actions,
>               .get_func = get_map,
>       },
> @@ -294,6 +313,7 @@ static param_t parameters[] =
>               .prop_name = WACOM_PROP_STRIPBUTTONS,
>               .prop_format = 8,
>               .prop_offset = 0,
> +             .arg_count = 0,
>               .set_func = map_actions,
>               .get_func = get_map,
>       },
> @@ -303,6 +323,7 @@ static param_t parameters[] =
>               .prop_name = WACOM_PROP_STRIPBUTTONS,
>               .prop_format = 8,
>               .prop_offset = 1,
> +             .arg_count = 0,
>               .set_func = map_actions,
>               .get_func = get_map,
>       },
> @@ -312,6 +333,7 @@ static param_t parameters[] =
>               .prop_name = WACOM_PROP_STRIPBUTTONS,
>               .prop_format = 8,
>               .prop_offset = 2,
> +             .arg_count = 0,
>               .set_func = map_actions,
>               .get_func = get_map,
>       },
> @@ -321,6 +343,7 @@ static param_t parameters[] =
>               .prop_name = WACOM_PROP_STRIPBUTTONS,
>               .prop_format = 8,
>               .prop_offset = 3,
> +             .arg_count = 0,
>               .set_func = map_actions,
>               .get_func = get_map,
>       },
> @@ -331,6 +354,7 @@ static param_t parameters[] =
>               .prop_name = WACOM_PROP_PRESSURE_THRESHOLD,
>               .prop_format = 32,
>               .prop_offset = 0,
> +             .arg_count = 1,
>       },
>       {
>               .name = "ResetArea",
> @@ -338,6 +362,7 @@ static param_t parameters[] =
>               .prop_name = WACOM_PROP_TABLET_AREA,
>               .prop_format = 32,
>               .prop_offset = 0,
> +             .arg_count = 0,
>               .prop_flags = PROP_FLAG_WRITEONLY,
>               .set_func = set_xydefault,
>       },
> @@ -369,6 +394,7 @@ static param_t parameters[] =
>               .name = "MapToOutput",
>               .desc = "Map the device to the given output. ",
>               .set_func = set_output,
> +             .arg_count = 1,
>               .prop_flags = PROP_FLAG_WRITEONLY
>       },
>       {
> @@ -2159,7 +2185,7 @@ static void get_param(Display *dpy, XDevice *dev, 
> param_t *param, int argc, char
>       switch(param->prop_format)
>       {
>               case 8:
> -                     for (i = 0; i < 1 + param->prop_extra; i++)
> +                     for (i = 0; i < param->arg_count; i++)
>                       {
>                               int val = data[param->prop_offset + i];
>  
> @@ -2168,18 +2194,18 @@ static void get_param(Display *dpy, XDevice *dev, 
> param_t *param, int argc, char
>                               else
>                                       sprintf(&str[strlen(str)], "%d", val);
>  
> -                             if (i < param->prop_extra)
> +                             if (i < param->arg_count - 1)
>                                       strcat(str, " ");
>                       }
>                       print_value(param, "%s", str);
>                       break;
>               case 32:
> -                     for (i = 0; i < 1 + param->prop_extra; i++)
> +                     for (i = 0; i < param->arg_count; i++)
>                       {
>                               long *ldata = (long*)data;
>                               sprintf(&str[strlen(str)], "%ld", 
> ldata[param->prop_offset + i]);
>  
> -                             if (i < param->prop_extra)
> +                             if (i < param->arg_count - 1)
>                                       strcat(str, " ");
>                       }
>                       print_value(param, "%s", str);
> -- 
> 1.7.4.1
> 
> 
> ------------------------------------------------------------------------------
> Create and publish websites with WebMatrix
> Use the most popular FREE web apps or write code yourself; 
> WebMatrix provides all the features you need to develop and 
> publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
> _______________________________________________
> Linuxwacom-devel mailing list
> Linuxwacom-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
> 

------------------------------------------------------------------------------
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself; 
WebMatrix provides all the features you need to develop and 
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to