summaryrefslogtreecommitdiff
path: root/Xi/getdctl.c
diff options
context:
space:
mode:
authorAdam Jackson <ajax@benzedrine.nwnk.net>2007-03-18 17:39:08 -0400
committerAdam Jackson <ajax@benzedrine.nwnk.net>2007-03-25 21:18:39 -0400
commite88fa75c9b468b88bb7b87b1da235c6eb2fe8164 (patch)
treeec72adcd230712e9be571c230e88813c45da0c48 /Xi/getdctl.c
parent4b5802ddbd45271be3cadeae0a83a6742df2515b (diff)
Static cleanup on Xi/
Diffstat (limited to 'Xi/getdctl.c')
-rw-r--r--Xi/getdctl.c213
1 files changed, 106 insertions, 107 deletions
diff --git a/Xi/getdctl.c b/Xi/getdctl.c
index d738ef83b..c264d4f8c 100644
--- a/Xi/getdctl.c
+++ b/Xi/getdctl.c
@@ -88,112 +88,11 @@ SProcXGetDeviceControl(register ClientPtr client)
/***********************************************************************
*
- * Get the state of the specified device control.
- *
- */
-
-int
-ProcXGetDeviceControl(ClientPtr client)
-{
- int total_length = 0;
- char *buf, *savbuf;
- register DeviceIntPtr dev;
- xGetDeviceControlReply rep;
-
- REQUEST(xGetDeviceControlReq);
- REQUEST_SIZE_MATCH(xGetDeviceControlReq);
-
- dev = LookupDeviceIntRec(stuff->deviceid);
- if (dev == NULL) {
- SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0, BadDevice);
- return Success;
- }
-
- rep.repType = X_Reply;
- rep.RepType = X_GetDeviceControl;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-
- switch (stuff->control) {
- case DEVICE_RESOLUTION:
- if (!dev->valuator) {
- SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0,
- BadMatch);
- return Success;
- }
- total_length = sizeof(xDeviceResolutionState) +
- (3 * sizeof(int) * dev->valuator->numAxes);
- break;
- case DEVICE_ABS_CALIB:
- if (!dev->absolute) {
- SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0,
- BadMatch);
- return Success;
- }
-
- total_length = sizeof(xDeviceAbsCalibCtl);
- break;
- case DEVICE_ABS_AREA:
- if (!dev->absolute) {
- SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0,
- BadMatch);
- return Success;
- }
-
- total_length = sizeof(xDeviceAbsAreaCtl);
- break;
- case DEVICE_CORE:
- total_length = sizeof(xDeviceCoreCtl);
- break;
- case DEVICE_ENABLE:
- total_length = sizeof(xDeviceEnableCtl);
- break;
- default:
- SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0, BadValue);
- return Success;
- }
-
- buf = (char *)xalloc(total_length);
- if (!buf) {
- SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0, BadAlloc);
- return Success;
- }
- savbuf = buf;
-
- switch (stuff->control) {
- case DEVICE_RESOLUTION:
- CopySwapDeviceResolution(client, dev->valuator, buf, total_length);
- break;
- case DEVICE_ABS_CALIB:
- CopySwapDeviceAbsCalib(client, dev->absolute, buf);
- break;
- case DEVICE_ABS_AREA:
- CopySwapDeviceAbsArea(client, dev->absolute, buf);
- break;
- case DEVICE_CORE:
- CopySwapDeviceCore(client, dev, buf);
- break;
- case DEVICE_ENABLE:
- CopySwapDeviceEnable(client, dev, buf);
- break;
- default:
- break;
- }
-
- rep.length = (total_length + 3) >> 2;
- WriteReplyToClient(client, sizeof(xGetDeviceControlReply), &rep);
- WriteToClient(client, total_length, savbuf);
- xfree(savbuf);
- return Success;
-}
-
-/***********************************************************************
- *
* This procedure copies DeviceResolution data, swapping if necessary.
*
*/
-void
+static void
CopySwapDeviceResolution(ClientPtr client, ValuatorClassPtr v, char *buf,
int length)
{
@@ -225,7 +124,7 @@ CopySwapDeviceResolution(ClientPtr client, ValuatorClassPtr v, char *buf,
}
}
-void CopySwapDeviceAbsCalib (ClientPtr client, AbsoluteClassPtr dts,
+static void CopySwapDeviceAbsCalib (ClientPtr client, AbsoluteClassPtr dts,
char *buf)
{
register char n;
@@ -256,7 +155,7 @@ void CopySwapDeviceAbsCalib (ClientPtr client, AbsoluteClassPtr dts,
}
}
-void CopySwapDeviceAbsArea (ClientPtr client, AbsoluteClassPtr dts,
+static void CopySwapDeviceAbsArea (ClientPtr client, AbsoluteClassPtr dts,
char *buf)
{
register char n;
@@ -283,7 +182,7 @@ void CopySwapDeviceAbsArea (ClientPtr client, AbsoluteClassPtr dts,
}
}
-void CopySwapDeviceCore (ClientPtr client, DeviceIntPtr dev, char *buf)
+static void CopySwapDeviceCore (ClientPtr client, DeviceIntPtr dev, char *buf)
{
register char n;
xDeviceCoreState *c = (xDeviceCoreState *) buf;
@@ -300,7 +199,7 @@ void CopySwapDeviceCore (ClientPtr client, DeviceIntPtr dev, char *buf)
}
}
-void CopySwapDeviceEnable (ClientPtr client, DeviceIntPtr dev, char *buf)
+static void CopySwapDeviceEnable (ClientPtr client, DeviceIntPtr dev, char *buf)
{
register char n;
xDeviceEnableState *e = (xDeviceEnableState *) buf;
@@ -316,7 +215,6 @@ void CopySwapDeviceEnable (ClientPtr client, DeviceIntPtr dev, char *buf)
}
}
-
/***********************************************************************
*
* This procedure writes the reply for the xGetDeviceControl function,
@@ -333,3 +231,104 @@ SRepXGetDeviceControl(ClientPtr client, int size, xGetDeviceControlReply * rep)
swapl(&rep->length, n);
WriteToClient(client, size, (char *)rep);
}
+
+/***********************************************************************
+ *
+ * Get the state of the specified device control.
+ *
+ */
+
+int
+ProcXGetDeviceControl(ClientPtr client)
+{
+ int total_length = 0;
+ char *buf, *savbuf;
+ register DeviceIntPtr dev;
+ xGetDeviceControlReply rep;
+
+ REQUEST(xGetDeviceControlReq);
+ REQUEST_SIZE_MATCH(xGetDeviceControlReq);
+
+ dev = LookupDeviceIntRec(stuff->deviceid);
+ if (dev == NULL) {
+ SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0, BadDevice);
+ return Success;
+ }
+
+ rep.repType = X_Reply;
+ rep.RepType = X_GetDeviceControl;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ switch (stuff->control) {
+ case DEVICE_RESOLUTION:
+ if (!dev->valuator) {
+ SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0,
+ BadMatch);
+ return Success;
+ }
+ total_length = sizeof(xDeviceResolutionState) +
+ (3 * sizeof(int) * dev->valuator->numAxes);
+ break;
+ case DEVICE_ABS_CALIB:
+ if (!dev->absolute) {
+ SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0,
+ BadMatch);
+ return Success;
+ }
+
+ total_length = sizeof(xDeviceAbsCalibCtl);
+ break;
+ case DEVICE_ABS_AREA:
+ if (!dev->absolute) {
+ SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0,
+ BadMatch);
+ return Success;
+ }
+
+ total_length = sizeof(xDeviceAbsAreaCtl);
+ break;
+ case DEVICE_CORE:
+ total_length = sizeof(xDeviceCoreCtl);
+ break;
+ case DEVICE_ENABLE:
+ total_length = sizeof(xDeviceEnableCtl);
+ break;
+ default:
+ SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0, BadValue);
+ return Success;
+ }
+
+ buf = (char *)xalloc(total_length);
+ if (!buf) {
+ SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0, BadAlloc);
+ return Success;
+ }
+ savbuf = buf;
+
+ switch (stuff->control) {
+ case DEVICE_RESOLUTION:
+ CopySwapDeviceResolution(client, dev->valuator, buf, total_length);
+ break;
+ case DEVICE_ABS_CALIB:
+ CopySwapDeviceAbsCalib(client, dev->absolute, buf);
+ break;
+ case DEVICE_ABS_AREA:
+ CopySwapDeviceAbsArea(client, dev->absolute, buf);
+ break;
+ case DEVICE_CORE:
+ CopySwapDeviceCore(client, dev, buf);
+ break;
+ case DEVICE_ENABLE:
+ CopySwapDeviceEnable(client, dev, buf);
+ break;
+ default:
+ break;
+ }
+
+ rep.length = (total_length + 3) >> 2;
+ WriteReplyToClient(client, sizeof(xGetDeviceControlReply), &rep);
+ WriteToClient(client, total_length, savbuf);
+ xfree(savbuf);
+ return Success;
+}