summaryrefslogtreecommitdiff
path: root/xserver/Xi/chgfctl.c
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@cvs.openbsd.org>2008-11-02 15:26:35 +0000
committerMatthieu Herrb <matthieu@cvs.openbsd.org>2008-11-02 15:26:35 +0000
commitdbca69c8a4f3e2d1ccb4f89152213b2861b33af6 (patch)
treef8963ef73903a7b4374adc2354dffbaa905112ac /xserver/Xi/chgfctl.c
parent33b2029f322f3c238b7ba528083195ad8dde33e1 (diff)
xserver 1.5.2. tested by ckuethe@, oga@, and others.
Diffstat (limited to 'xserver/Xi/chgfctl.c')
-rw-r--r--xserver/Xi/chgfctl.c183
1 files changed, 60 insertions, 123 deletions
diff --git a/xserver/Xi/chgfctl.c b/xserver/Xi/chgfctl.c
index 235d65968..3155e87c2 100644
--- a/xserver/Xi/chgfctl.c
+++ b/xserver/Xi/chgfctl.c
@@ -56,14 +56,10 @@ 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/extensions/XI.h>
#include <X11/extensions/XIproto.h> /* control constants */
-#include "extnsionst.h"
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "chgfctl.h"
@@ -119,9 +115,7 @@ ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
t = defaultKeyboardControl.click;
else if (t < 0 || t > 100) {
client->errorValue = t;
- SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0,
- BadValue);
- return Success;
+ return BadValue;
}
kctrl.click = t;
}
@@ -132,9 +126,7 @@ ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
t = defaultKeyboardControl.bell;
else if (t < 0 || t > 100) {
client->errorValue = t;
- SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0,
- BadValue);
- return Success;
+ return BadValue;
}
kctrl.bell = t;
}
@@ -145,9 +137,7 @@ ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
t = defaultKeyboardControl.bell_pitch;
else if (t < 0) {
client->errorValue = t;
- SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0,
- BadValue);
- return Success;
+ return BadValue;
}
kctrl.bell_pitch = t;
}
@@ -158,9 +148,7 @@ ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
t = defaultKeyboardControl.bell_duration;
else if (t < 0) {
client->errorValue = t;
- SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0,
- BadValue);
- return Success;
+ return BadValue;
}
kctrl.bell_duration = t;
}
@@ -174,15 +162,10 @@ ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
key = (KeyCode) f->key;
if (key < 8 || key > 255) {
client->errorValue = key;
- SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0,
- BadValue);
- return Success;
- }
- if (!(mask & DvAutoRepeatMode)) {
- SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0,
- BadMatch);
- return Success;
+ return BadValue;
}
+ if (!(mask & DvAutoRepeatMode))
+ return BadMatch;
}
if (mask & DvAutoRepeatMode) {
@@ -210,9 +193,7 @@ ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
(defaultKeyboardControl.autoRepeats[inx] & kmask);
} else {
client->errorValue = t;
- SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0,
- BadValue);
- return Success;
+ return BadValue;
}
}
@@ -250,9 +231,7 @@ ChangePtrFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
pctrl.num = defaultPointerControl.num;
else if (accelNum < 0) {
client->errorValue = accelNum;
- SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0,
- BadValue);
- return Success;
+ return BadValue;
} else
pctrl.num = accelNum;
}
@@ -265,9 +244,7 @@ ChangePtrFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
pctrl.den = defaultPointerControl.den;
else if (accelDenom <= 0) {
client->errorValue = accelDenom;
- SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0,
- BadValue);
- return Success;
+ return BadValue;
} else
pctrl.den = accelDenom;
}
@@ -280,9 +257,7 @@ ChangePtrFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
pctrl.threshold = defaultPointerControl.threshold;
else if (threshold < 0) {
client->errorValue = threshold;
- SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0,
- BadValue);
- return Success;
+ return BadValue;
} else
pctrl.threshold = threshold;
}
@@ -336,21 +311,16 @@ ChangeStringFeedback(ClientPtr client, DeviceIntPtr dev,
SwapLongs((CARD32 *) syms, f->num_keysyms);
}
- if (f->num_keysyms > s->ctrl.max_symbols) {
- SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0,
- BadValue);
- return Success;
- }
+ if (f->num_keysyms > s->ctrl.max_symbols)
+ return BadValue;
+
sup_syms = s->ctrl.symbols_supported;
for (i = 0; i < f->num_keysyms; i++) {
for (j = 0; j < s->ctrl.num_symbols_supported; j++)
if (*(syms + i) == *(sup_syms + j))
break;
- if (j == s->ctrl.num_symbols_supported) {
- SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0,
- BadMatch);
- return Success;
- }
+ if (j == s->ctrl.num_symbols_supported)
+ return BadMatch;
}
s->ctrl.num_symbols_displayed = f->num_keysyms;
@@ -388,9 +358,7 @@ ChangeBellFeedback(ClientPtr client, DeviceIntPtr dev,
t = defaultKeyboardControl.bell;
else if (t < 0 || t > 100) {
client->errorValue = t;
- SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0,
- BadValue);
- return Success;
+ return BadValue;
}
bctrl.percent = t;
}
@@ -401,9 +369,7 @@ ChangeBellFeedback(ClientPtr client, DeviceIntPtr dev,
t = defaultKeyboardControl.bell_pitch;
else if (t < 0) {
client->errorValue = t;
- SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0,
- BadValue);
- return Success;
+ return BadValue;
}
bctrl.pitch = t;
}
@@ -414,9 +380,7 @@ ChangeBellFeedback(ClientPtr client, DeviceIntPtr dev,
t = defaultKeyboardControl.bell_duration;
else if (t < 0) {
client->errorValue = t;
- SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0,
- BadValue);
- return Success;
+ return BadValue;
}
bctrl.duration = t;
}
@@ -474,44 +438,34 @@ ProcXChangeFeedbackControl(ClientPtr client)
StringFeedbackPtr s;
BellFeedbackPtr b;
LedFeedbackPtr l;
+ int rc;
REQUEST(xChangeFeedbackControlReq);
REQUEST_AT_LEAST_SIZE(xChangeFeedbackControlReq);
len = stuff->length - (sizeof(xChangeFeedbackControlReq) >> 2);
- dev = LookupDeviceIntRec(stuff->deviceid);
- if (dev == NULL) {
- SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0,
- BadDevice);
- return Success;
- }
+ rc = dixLookupDevice(&dev, stuff->deviceid, client, DixManageAccess);
+ if (rc != Success)
+ return rc;
switch (stuff->feedbackid) {
case KbdFeedbackClass:
- if (len != (sizeof(xKbdFeedbackCtl) >> 2)) {
- SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl,
- 0, BadLength);
- return Success;
- }
+ if (len != (sizeof(xKbdFeedbackCtl) >> 2))
+ return BadLength;
+
for (k = dev->kbdfeed; k; k = k->next)
- if (k->ctrl.id == ((xKbdFeedbackCtl *) & stuff[1])->id) {
- ChangeKbdFeedback(client, dev, stuff->mask, k,
- (xKbdFeedbackCtl *) & stuff[1]);
- return Success;
- }
+ if (k->ctrl.id == ((xKbdFeedbackCtl *) & stuff[1])->id)
+ return ChangeKbdFeedback(client, dev, stuff->mask, k,
+ (xKbdFeedbackCtl *) & stuff[1]);
break;
case PtrFeedbackClass:
- if (len != (sizeof(xPtrFeedbackCtl) >> 2)) {
- SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl,
- 0, BadLength);
- return Success;
- }
+ if (len != (sizeof(xPtrFeedbackCtl) >> 2))
+ return BadLength;
+
for (p = dev->ptrfeed; p; p = p->next)
- if (p->ctrl.id == ((xPtrFeedbackCtl *) & stuff[1])->id) {
- ChangePtrFeedback(client, dev, stuff->mask, p,
- (xPtrFeedbackCtl *) & stuff[1]);
- return Success;
- }
+ if (p->ctrl.id == ((xPtrFeedbackCtl *) & stuff[1])->id)
+ return ChangePtrFeedback(client, dev, stuff->mask, p,
+ (xPtrFeedbackCtl *) & stuff[1]);
break;
case StringFeedbackClass:
{
@@ -521,63 +475,46 @@ ProcXChangeFeedbackControl(ClientPtr client)
if (client->swapped) {
swaps(&f->num_keysyms, n);
}
- if (len != ((sizeof(xStringFeedbackCtl) >> 2) + f->num_keysyms)) {
- SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl,
- 0, BadLength);
- return Success;
- }
+ if (len != ((sizeof(xStringFeedbackCtl) >> 2) + f->num_keysyms))
+ return BadLength;
+
for (s = dev->stringfeed; s; s = s->next)
- if (s->ctrl.id == ((xStringFeedbackCtl *) & stuff[1])->id) {
- ChangeStringFeedback(client, dev, stuff->mask, s,
- (xStringFeedbackCtl *) & stuff[1]);
- return Success;
- }
+ if (s->ctrl.id == ((xStringFeedbackCtl *) & stuff[1])->id)
+ return ChangeStringFeedback(client, dev, stuff->mask, s,
+ (xStringFeedbackCtl *) & stuff[1]);
break;
}
case IntegerFeedbackClass:
- if (len != (sizeof(xIntegerFeedbackCtl) >> 2)) {
- SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl,
- 0, BadLength);
- return Success;
- }
+ if (len != (sizeof(xIntegerFeedbackCtl) >> 2))
+ return BadLength;
+
for (i = dev->intfeed; i; i = i->next)
- if (i->ctrl.id == ((xIntegerFeedbackCtl *) & stuff[1])->id) {
- ChangeIntegerFeedback(client, dev, stuff->mask, i,
- (xIntegerFeedbackCtl *) & stuff[1]);
- return Success;
- }
+ if (i->ctrl.id == ((xIntegerFeedbackCtl *) & stuff[1])->id)
+ return ChangeIntegerFeedback(client, dev, stuff->mask, i,
+ (xIntegerFeedbackCtl *)&stuff[1]);
break;
case LedFeedbackClass:
- if (len != (sizeof(xLedFeedbackCtl) >> 2)) {
- SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl,
- 0, BadLength);
- return Success;
- }
+ if (len != (sizeof(xLedFeedbackCtl) >> 2))
+ return BadLength;
+
for (l = dev->leds; l; l = l->next)
- if (l->ctrl.id == ((xLedFeedbackCtl *) & stuff[1])->id) {
- ChangeLedFeedback(client, dev, stuff->mask, l,
- (xLedFeedbackCtl *) & stuff[1]);
- return Success;
- }
+ if (l->ctrl.id == ((xLedFeedbackCtl *) & stuff[1])->id)
+ return ChangeLedFeedback(client, dev, stuff->mask, l,
+ (xLedFeedbackCtl *) & stuff[1]);
break;
case BellFeedbackClass:
- if (len != (sizeof(xBellFeedbackCtl) >> 2)) {
- SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl,
- 0, BadLength);
- return Success;
- }
+ if (len != (sizeof(xBellFeedbackCtl) >> 2))
+ return BadLength;
+
for (b = dev->bell; b; b = b->next)
- if (b->ctrl.id == ((xBellFeedbackCtl *) & stuff[1])->id) {
- ChangeBellFeedback(client, dev, stuff->mask, b,
- (xBellFeedbackCtl *) & stuff[1]);
- return Success;
- }
+ if (b->ctrl.id == ((xBellFeedbackCtl *) & stuff[1])->id)
+ return ChangeBellFeedback(client, dev, stuff->mask, b,
+ (xBellFeedbackCtl *) & stuff[1]);
break;
default:
break;
}
- SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, BadMatch);
- return Success;
+ return BadMatch;
}