summaryrefslogtreecommitdiff
path: root/Xi/listdev.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2012-03-21 12:55:09 -0700
committerKeith Packard <keithp@keithp.com>2012-03-21 13:54:42 -0700
commit9838b7032ea9792bec21af424c53c07078636d21 (patch)
treeb72d0827dac50f0f3b8eab29b3b7639546d735d7 /Xi/listdev.c
parent75199129c603fc8567185ac31866c9518193cb78 (diff)
Introduce a consistent coding style
This is strictly the application of the script 'x-indent-all.sh' from util/modular. Compared to the patch that Daniel posted in January, I've added a few indent flags: -bap -psl -T PrivatePtr -T pmWait -T _XFUNCPROTOBEGIN -T _XFUNCPROTOEND -T _X_EXPORT The typedefs were needed to make the output of sdksyms.sh match the previous output, otherwise, the code is formatted badly enough that sdksyms.sh generates incorrect output. The generated code was compared with the previous version and found to be essentially identical -- "assert" line numbers and BUILD_TIME were the only differences found. The comparison was done with this script: dir1=$1 dir2=$2 for dir in $dir1 $dir2; do (cd $dir && find . -name '*.o' | while read file; do dir=`dirname $file` base=`basename $file .o` dump=$dir/$base.dump objdump -d $file > $dump done) done find $dir1 -name '*.dump' | while read dump; do otherdump=`echo $dump | sed "s;$dir1;$dir2;"` diff -u $dump $otherdump done Signed-off-by: Keith Packard <keithp@keithp.com> Acked-by: Daniel Stone <daniel@fooishbar.org> Acked-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'Xi/listdev.c')
-rw-r--r--Xi/listdev.c133
1 files changed, 65 insertions, 68 deletions
diff --git a/Xi/listdev.c b/Xi/listdev.c
index 1b3081d96..a02112f32 100644
--- a/Xi/listdev.c
+++ b/Xi/listdev.c
@@ -54,9 +54,9 @@ SOFTWARE.
#include <dix-config.h>
#endif
-#include <X11/X.h> /* for inputstr.h */
-#include <X11/Xproto.h> /* Request macro */
-#include "inputstr.h" /* DeviceIntPtr */
+#include <X11/X.h> /* for inputstr.h */
+#include <X11/Xproto.h> /* Request macro */
+#include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "XIstubs.h"
@@ -68,7 +68,6 @@ SOFTWARE.
#include "listdev.h"
-
/***********************************************************************
*
* This procedure lists the input devices available to the server.
@@ -97,15 +96,15 @@ SizeDeviceInfo(DeviceIntPtr d, int *namesize, int *size)
*namesize += 1;
if (d->name)
- *namesize += strlen(d->name);
+ *namesize += strlen(d->name);
if (d->key != NULL)
- *size += sizeof(xKeyInfo);
+ *size += sizeof(xKeyInfo);
if (d->button != NULL)
- *size += sizeof(xButtonInfo);
+ *size += sizeof(xButtonInfo);
if (d->valuator != NULL) {
- chunks = ((int)d->valuator->numAxes + 19) / VPC;
- *size += (chunks * sizeof(xValuatorInfo) +
- d->valuator->numAxes * sizeof(xAxisInfo));
+ chunks = ((int) d->valuator->numAxes + 19) / VPC;
+ *size += (chunks * sizeof(xValuatorInfo) +
+ d->valuator->numAxes * sizeof(xAxisInfo));
}
}
@@ -122,15 +121,16 @@ SizeDeviceInfo(DeviceIntPtr d, int *namesize, int *size)
static void
CopyDeviceName(char **namebuf, char *name)
{
- char *nameptr = (char *)*namebuf;
+ char *nameptr = (char *) *namebuf;
if (name) {
- *nameptr++ = strlen(name);
- strcpy(nameptr, name);
- *namebuf += (strlen(name) + 1);
- } else {
- *nameptr++ = 0;
- *namebuf += 1;
+ *nameptr++ = strlen(name);
+ strcpy(nameptr, name);
+ *namebuf += (strlen(name) + 1);
+ }
+ else {
+ *nameptr++ = 0;
+ *namebuf += 1;
}
}
@@ -150,7 +150,7 @@ CopySwapButtonClass(ClientPtr client, ButtonClassPtr b, char **buf)
b2->length = sizeof(xButtonInfo);
b2->num_buttons = b->numButtons;
if (client && client->swapped) {
- swaps(&b2->num_buttons);
+ swaps(&b2->num_buttons);
}
*buf += sizeof(xButtonInfo);
}
@@ -162,8 +162,7 @@ CopySwapButtonClass(ClientPtr client, ButtonClassPtr b, char **buf)
*/
static void
-CopySwapDevice(ClientPtr client, DeviceIntPtr d, int num_classes,
- char **buf)
+CopySwapDevice(ClientPtr client, DeviceIntPtr d, int num_classes, char **buf)
{
xDeviceInfoPtr dev;
@@ -173,18 +172,18 @@ CopySwapDevice(ClientPtr client, DeviceIntPtr d, int num_classes,
dev->type = d->xinput_type;
dev->num_classes = num_classes;
if (IsMaster(d) && IsKeyboardDevice(d))
- dev->use = IsXKeyboard;
+ dev->use = IsXKeyboard;
else if (IsMaster(d) && IsPointerDevice(d))
- dev->use = IsXPointer;
+ dev->use = IsXPointer;
else if (d->valuator && d->button)
dev->use = IsXExtensionPointer;
else if (d->key && d->kbdfeed)
dev->use = IsXExtensionKeyboard;
else
- dev->use = IsXExtensionDevice;
+ dev->use = IsXExtensionDevice;
if (client->swapped) {
- swapl(&dev->type);
+ swapl(&dev->type);
}
*buf += sizeof(xDeviceInfo);
}
@@ -207,7 +206,7 @@ CopySwapKeyClass(ClientPtr client, KeyClassPtr k, char **buf)
k2->max_keycode = k->xkbInfo->desc->max_key_code;
k2->num_keys = k2->max_keycode - k2->min_keycode + 1;
if (client && client->swapped) {
- swaps(&k2->num_keys);
+ swaps(&k2->num_keys);
}
*buf += sizeof(xKeyInfo);
}
@@ -234,54 +233,53 @@ CopySwapValuatorClass(ClientPtr client, DeviceIntPtr dev, char **buf)
xAxisInfoPtr a2;
for (i = 0, axes = v->numAxes; i < ((v->numAxes + 19) / VPC);
- i++, axes -= VPC) {
- t_axes = axes < VPC ? axes : VPC;
- if (t_axes < 0)
- t_axes = v->numAxes % VPC;
- v2 = (xValuatorInfoPtr) * buf;
- v2->class = ValuatorClass;
- v2->length = sizeof(xValuatorInfo) + t_axes * sizeof(xAxisInfo);
- v2->num_axes = t_axes;
- v2->mode = valuator_get_mode(dev, 0);
- v2->motion_buffer_size = v->numMotionEvents;
- if (client && client->swapped) {
- swapl(&v2->motion_buffer_size);
- }
- *buf += sizeof(xValuatorInfo);
- a = v->axes + (VPC * i);
- a2 = (xAxisInfoPtr) * buf;
- for (j = 0; j < t_axes; j++) {
- a2->min_value = a->min_value;
- a2->max_value = a->max_value;
- a2->resolution = a->resolution;
- if (client && client->swapped) {
- swapl(&a2->min_value);
- swapl(&a2->max_value);
- swapl(&a2->resolution);
- }
- a2++;
- a++;
- *buf += sizeof(xAxisInfo);
- }
+ i++, axes -= VPC) {
+ t_axes = axes < VPC ? axes : VPC;
+ if (t_axes < 0)
+ t_axes = v->numAxes % VPC;
+ v2 = (xValuatorInfoPtr) * buf;
+ v2->class = ValuatorClass;
+ v2->length = sizeof(xValuatorInfo) + t_axes * sizeof(xAxisInfo);
+ v2->num_axes = t_axes;
+ v2->mode = valuator_get_mode(dev, 0);
+ v2->motion_buffer_size = v->numMotionEvents;
+ if (client && client->swapped) {
+ swapl(&v2->motion_buffer_size);
+ }
+ *buf += sizeof(xValuatorInfo);
+ a = v->axes + (VPC * i);
+ a2 = (xAxisInfoPtr) * buf;
+ for (j = 0; j < t_axes; j++) {
+ a2->min_value = a->min_value;
+ a2->max_value = a->max_value;
+ a2->resolution = a->resolution;
+ if (client && client->swapped) {
+ swapl(&a2->min_value);
+ swapl(&a2->max_value);
+ swapl(&a2->resolution);
+ }
+ a2++;
+ a++;
+ *buf += sizeof(xAxisInfo);
+ }
}
return i;
}
static void
CopySwapClasses(ClientPtr client, DeviceIntPtr dev, CARD8 *num_classes,
- char** classbuf)
+ char **classbuf)
{
if (dev->key != NULL) {
- CopySwapKeyClass(client, dev->key, classbuf);
- (*num_classes)++;
+ CopySwapKeyClass(client, dev->key, classbuf);
+ (*num_classes)++;
}
if (dev->button != NULL) {
- CopySwapButtonClass(client, dev->button, classbuf);
- (*num_classes)++;
+ CopySwapButtonClass(client, dev->button, classbuf);
+ (*num_classes)++;
}
if (dev->valuator != NULL) {
- (*num_classes) +=
- CopySwapValuatorClass(client, dev, classbuf);
+ (*num_classes) += CopySwapValuatorClass(client, dev, classbuf);
}
}
@@ -293,7 +291,7 @@ CopySwapClasses(ClientPtr client, DeviceIntPtr dev, CARD8 *num_classes,
static void
ListDeviceInfo(ClientPtr client, DeviceIntPtr d, xDeviceInfoPtr dev,
- char **devbuf, char **classbuf, char **namebuf)
+ char **devbuf, char **classbuf, char **namebuf)
{
CopyDeviceName(namebuf, d->name);
CopySwapDevice(client, d, 0, devbuf);
@@ -310,16 +308,15 @@ static Bool
ShouldSkipDevice(ClientPtr client, DeviceIntPtr d)
{
/* don't send master devices other than VCP/VCK */
- if (!IsMaster(d) || d == inputInfo.pointer || d == inputInfo.keyboard)
- {
+ if (!IsMaster(d) || d == inputInfo.pointer ||d == inputInfo.keyboard) {
int rc = XaceHook(XACE_DEVICE_ACCESS, client, d, DixGetAttrAccess);
+
if (rc == Success)
return FALSE;
}
return TRUE;
}
-
/***********************************************************************
*
* This procedure lists the input devices available to the server.
@@ -335,7 +332,7 @@ ProcXListInputDevices(ClientPtr client)
{
xListInputDevicesReply rep;
int numdevs = 0;
- int namesize = 1; /* need 1 extra byte for strcpy */
+ int namesize = 1; /* need 1 extra byte for strcpy */
int i = 0, size = 0;
int total_length;
char *devbuf, *classbuf, *namebuf, *savbuf;
@@ -378,7 +375,7 @@ ProcXListInputDevices(ClientPtr client)
/* allocate space for reply */
total_length = numdevs * sizeof(xDeviceInfo) + size + namesize;
- devbuf = (char *)calloc(1, total_length);
+ devbuf = (char *) calloc(1, total_length);
classbuf = devbuf + (numdevs * sizeof(xDeviceInfo));
namebuf = classbuf + size;
savbuf = devbuf;
@@ -420,5 +417,5 @@ SRepXListInputDevices(ClientPtr client, int size, xListInputDevicesReply * rep)
{
swaps(&rep->sequenceNumber);
swapl(&rep->length);
- WriteToClient(client, size, (char *)rep);
+ WriteToClient(client, size, (char *) rep);
}