summaryrefslogtreecommitdiff
path: root/Xi/listdev.c
diff options
context:
space:
mode:
Diffstat (limited to 'Xi/listdev.c')
-rw-r--r--Xi/listdev.c260
1 files changed, 130 insertions, 130 deletions
diff --git a/Xi/listdev.c b/Xi/listdev.c
index 33266ae4c..a9fd40156 100644
--- a/Xi/listdev.c
+++ b/Xi/listdev.c
@@ -77,9 +77,9 @@ SOFTWARE.
*/
int
-SProcXListInputDevices(register ClientPtr client)
+SProcXListInputDevices(ClientPtr client)
{
- register char n;
+ char n;
REQUEST(xListInputDevicesReq);
swaps(&stuff->length, n);
@@ -88,80 +88,12 @@ SProcXListInputDevices(register ClientPtr client)
/***********************************************************************
*
- * This procedure lists the input devices available to the server.
- *
- */
-
-int
-ProcXListInputDevices(register ClientPtr client)
-{
- xListInputDevicesReply rep;
- int numdevs = 0;
- int namesize = 1; /* need 1 extra byte for strcpy */
- int size = 0;
- int total_length;
- char *devbuf;
- char *classbuf;
- char *namebuf;
- char *savbuf;
- xDeviceInfo *dev;
- DeviceIntPtr d;
-
- REQUEST_SIZE_MATCH(xListInputDevicesReq);
-
- rep.repType = X_Reply;
- rep.RepType = X_ListInputDevices;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-
- AddOtherInputDevices();
-
- SizeDeviceInfo(inputInfo.keyboard, &namesize, &size);
- SizeDeviceInfo(inputInfo.pointer, &namesize, &size);
- numdevs = 2;
-
- for (d = inputInfo.devices; d; d = d->next) {
- SizeDeviceInfo(d, &namesize, &size);
- numdevs++;
- }
- for (d = inputInfo.off_devices; d; d = d->next) {
- SizeDeviceInfo(d, &namesize, &size);
- numdevs++;
- }
-
- total_length = numdevs * sizeof(xDeviceInfo) + size + namesize;
- devbuf = (char *)xalloc(total_length);
- classbuf = devbuf + (numdevs * sizeof(xDeviceInfo));
- namebuf = classbuf + size;
- savbuf = devbuf;
-
- dev = (xDeviceInfoPtr) devbuf;
- ListDeviceInfo(client, inputInfo.keyboard, dev++,
- &devbuf, &classbuf, &namebuf);
- ListDeviceInfo(client, inputInfo.pointer, dev++,
- &devbuf, &classbuf, &namebuf);
-
- for (d = inputInfo.devices; d; d = d->next, dev++)
- ListDeviceInfo(client, d, dev, &devbuf, &classbuf, &namebuf);
- for (d = inputInfo.off_devices; d; d = d->next, dev++)
- ListDeviceInfo(client, d, dev, &devbuf, &classbuf, &namebuf);
-
- rep.ndevices = numdevs;
- rep.length = (total_length + 3) >> 2;
- WriteReplyToClient(client, sizeof(xListInputDevicesReply), &rep);
- WriteToClient(client, total_length, savbuf);
- xfree(savbuf);
- return Success;
-}
-
-/***********************************************************************
- *
* This procedure calculates the size of the information to be returned
* for an input device.
*
*/
-void
+static void
SizeDeviceInfo(DeviceIntPtr d, int *namesize, int *size)
{
int chunks;
@@ -182,32 +114,6 @@ SizeDeviceInfo(DeviceIntPtr d, int *namesize, int *size)
/***********************************************************************
*
- * This procedure lists information to be returned for an input device.
- *
- */
-
-void
-ListDeviceInfo(ClientPtr client, DeviceIntPtr d, xDeviceInfoPtr dev,
- char **devbuf, char **classbuf, char **namebuf)
-{
- CopyDeviceName(namebuf, d->name);
- CopySwapDevice(client, d, 0, devbuf);
- if (d->key != NULL) {
- CopySwapKeyClass(client, d->key, classbuf);
- dev->num_classes++;
- }
- if (d->button != NULL) {
- CopySwapButtonClass(client, d->button, classbuf);
- dev->num_classes++;
- }
- if (d->valuator != NULL) {
- dev->num_classes +=
- CopySwapValuatorClass(client, d->valuator, classbuf);
- }
-}
-
-/***********************************************************************
- *
* This procedure copies data to the DeviceInfo struct, swapping if necessary.
*
* We need the extra byte in the allocated buffer, because the trailing null
@@ -216,7 +122,7 @@ ListDeviceInfo(ClientPtr client, DeviceIntPtr d, xDeviceInfoPtr dev,
*
*/
-void
+static void
CopyDeviceName(char **namebuf, char *name)
{
char *nameptr = (char *)*namebuf;
@@ -233,15 +139,37 @@ CopyDeviceName(char **namebuf, char *name)
/***********************************************************************
*
+ * This procedure copies ButtonClass information, swapping if necessary.
+ *
+ */
+
+static void
+CopySwapButtonClass(ClientPtr client, ButtonClassPtr b, char **buf)
+{
+ char n;
+ xButtonInfoPtr b2;
+
+ b2 = (xButtonInfoPtr) * buf;
+ b2->class = ButtonClass;
+ b2->length = sizeof(xButtonInfo);
+ b2->num_buttons = b->numButtons;
+ if (client->swapped) {
+ swaps(&b2->num_buttons, n); /* macro - braces are required */
+ }
+ *buf += sizeof(xButtonInfo);
+}
+
+/***********************************************************************
+ *
* This procedure copies data to the DeviceInfo struct, swapping if necessary.
*
*/
-void
-CopySwapDevice(register ClientPtr client, DeviceIntPtr d, int num_classes,
+static void
+CopySwapDevice(ClientPtr client, DeviceIntPtr d, int num_classes,
char **buf)
{
- register char n;
+ char n;
xDeviceInfoPtr dev;
dev = (xDeviceInfoPtr) * buf;
@@ -271,10 +199,10 @@ CopySwapDevice(register ClientPtr client, DeviceIntPtr d, int num_classes,
*
*/
-void
-CopySwapKeyClass(register ClientPtr client, KeyClassPtr k, char **buf)
+static void
+CopySwapKeyClass(ClientPtr client, KeyClassPtr k, char **buf)
{
- register char n;
+ char n;
xKeyInfoPtr k2;
k2 = (xKeyInfoPtr) * buf;
@@ -291,28 +219,6 @@ CopySwapKeyClass(register ClientPtr client, KeyClassPtr k, char **buf)
/***********************************************************************
*
- * This procedure copies ButtonClass information, swapping if necessary.
- *
- */
-
-void
-CopySwapButtonClass(register ClientPtr client, ButtonClassPtr b, char **buf)
-{
- register char n;
- xButtonInfoPtr b2;
-
- b2 = (xButtonInfoPtr) * buf;
- b2->class = ButtonClass;
- b2->length = sizeof(xButtonInfo);
- b2->num_buttons = b->numButtons;
- if (client->swapped) {
- swaps(&b2->num_buttons, n); /* macro - braces are required */
- }
- *buf += sizeof(xButtonInfo);
-}
-
-/***********************************************************************
- *
* This procedure copies ValuatorClass information, swapping if necessary.
*
* Devices may have up to 255 valuators. The length of a ValuatorClass is
@@ -323,11 +229,11 @@ CopySwapButtonClass(register ClientPtr client, ButtonClassPtr b, char **buf)
*
*/
-int
-CopySwapValuatorClass(register ClientPtr client, ValuatorClassPtr v, char **buf)
+static int
+CopySwapValuatorClass(ClientPtr client, ValuatorClassPtr v, char **buf)
{
int i, j, axes, t_axes;
- register char n;
+ char n;
xValuatorInfoPtr v2;
AxisInfo *a;
xAxisInfoPtr a2;
@@ -368,6 +274,100 @@ CopySwapValuatorClass(register ClientPtr client, ValuatorClassPtr v, char **buf)
/***********************************************************************
*
+ * This procedure lists information to be returned for an input device.
+ *
+ */
+
+static void
+ListDeviceInfo(ClientPtr client, DeviceIntPtr d, xDeviceInfoPtr dev,
+ char **devbuf, char **classbuf, char **namebuf)
+{
+ CopyDeviceName(namebuf, d->name);
+ CopySwapDevice(client, d, 0, devbuf);
+ if (d->key != NULL) {
+ CopySwapKeyClass(client, d->key, classbuf);
+ dev->num_classes++;
+ }
+ if (d->button != NULL) {
+ CopySwapButtonClass(client, d->button, classbuf);
+ dev->num_classes++;
+ }
+ if (d->valuator != NULL) {
+ dev->num_classes +=
+ CopySwapValuatorClass(client, d->valuator, classbuf);
+ }
+}
+
+/***********************************************************************
+ *
+ * This procedure lists the input devices available to the server.
+ *
+ */
+
+int
+ProcXListInputDevices(ClientPtr client)
+{
+ xListInputDevicesReply rep;
+ int numdevs = 0;
+ int namesize = 1; /* need 1 extra byte for strcpy */
+ int size = 0;
+ int total_length;
+ char *devbuf;
+ char *classbuf;
+ char *namebuf;
+ char *savbuf;
+ xDeviceInfo *dev;
+ DeviceIntPtr d;
+
+ REQUEST_SIZE_MATCH(xListInputDevicesReq);
+
+ rep.repType = X_Reply;
+ rep.RepType = X_ListInputDevices;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ AddOtherInputDevices();
+
+ SizeDeviceInfo(inputInfo.keyboard, &namesize, &size);
+ SizeDeviceInfo(inputInfo.pointer, &namesize, &size);
+ numdevs = 2;
+
+ for (d = inputInfo.devices; d; d = d->next) {
+ SizeDeviceInfo(d, &namesize, &size);
+ numdevs++;
+ }
+ for (d = inputInfo.off_devices; d; d = d->next) {
+ SizeDeviceInfo(d, &namesize, &size);
+ numdevs++;
+ }
+
+ total_length = numdevs * sizeof(xDeviceInfo) + size + namesize;
+ devbuf = (char *)xalloc(total_length);
+ classbuf = devbuf + (numdevs * sizeof(xDeviceInfo));
+ namebuf = classbuf + size;
+ savbuf = devbuf;
+
+ dev = (xDeviceInfoPtr) devbuf;
+ ListDeviceInfo(client, inputInfo.keyboard, dev++,
+ &devbuf, &classbuf, &namebuf);
+ ListDeviceInfo(client, inputInfo.pointer, dev++,
+ &devbuf, &classbuf, &namebuf);
+
+ for (d = inputInfo.devices; d; d = d->next, dev++)
+ ListDeviceInfo(client, d, dev, &devbuf, &classbuf, &namebuf);
+ for (d = inputInfo.off_devices; d; d = d->next, dev++)
+ ListDeviceInfo(client, d, dev, &devbuf, &classbuf, &namebuf);
+
+ rep.ndevices = numdevs;
+ rep.length = (total_length + 3) >> 2;
+ WriteReplyToClient(client, sizeof(xListInputDevicesReply), &rep);
+ WriteToClient(client, total_length, savbuf);
+ xfree(savbuf);
+ return Success;
+}
+
+/***********************************************************************
+ *
* This procedure writes the reply for the XListInputDevices function,
* if the client and server have a different byte ordering.
*
@@ -376,7 +376,7 @@ CopySwapValuatorClass(register ClientPtr client, ValuatorClassPtr v, char **buf)
void
SRepXListInputDevices(ClientPtr client, int size, xListInputDevicesReply * rep)
{
- register char n;
+ char n;
swaps(&rep->sequenceNumber, n);
swapl(&rep->length, n);