1
/* $Xorg: lbxexts.c,v 1.3 2000/08/17 19:53:31 cpqbld Exp $ */
3
* Copyright 1994 Network Computing Devices, Inc.
5
* Permission to use, copy, modify, distribute, and sell this software and
6
* its documentation for any purpose is hereby granted without fee, provided
7
* that the above copyright notice appear in all copies and that both that
8
* copyright notice and this permission notice appear in supporting
9
* documentation, and that the name Network Computing Devices, Inc. not be
10
* used in advertising or publicity pertaining to distribution of this
11
* software without specific, written prior permission.
13
* THIS SOFTWARE IS PROVIDED `AS-IS'. NETWORK COMPUTING DEVICES, INC.,
14
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT
15
* LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
16
* PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL NETWORK
17
* COMPUTING DEVICES, INC., BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING
18
* SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA,
19
* OR PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF
20
* WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF OR IN
21
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24
/* $XFree86: xc/programs/Xserver/lbx/lbxexts.c,v 1.4 2001/02/16 13:24:10 eich Exp $ */
29
#include "dixstruct.h"
30
#include "colormapst.h"
31
#include "propertyst.h"
36
#define _SECURITY_SERVER
37
#include "extensions/security.h"
40
typedef struct _lbxext {
56
static LbxExtensionEntry **lbx_extensions = NULL;
57
static int num_exts = 0;
61
LbxAddExtension(char *name,
67
LbxExtensionEntry *ext,
70
ext = (LbxExtensionEntry *) xalloc(sizeof(LbxExtensionEntry));
73
ext->name = (char *) xalloc(strlen(name) + 1);
75
ext->aliases = (char **) NULL;
80
strcpy(ext->name, name);
82
newexts = (LbxExtensionEntry **) xrealloc(lbx_extensions,
83
(i + 1) * sizeof(LbxExtensionEntry *));
90
lbx_extensions = newexts;
91
lbx_extensions[i] = ext;
94
ext->opcode = opcode;;
95
ext->ev_base = ev_base;;
96
ext->err_base = err_base;
108
LbxAddExtensionAlias(int idx,
113
LbxExtensionEntry *ext = lbx_extensions[idx];
115
aliases = (char **) xrealloc(ext->aliases,
116
(ext->num_aliases + 1) * sizeof(char *));
119
ext->aliases = aliases;
120
name = (char *) xalloc(strlen(alias) + 1);
124
ext->aliases[ext->num_aliases] = name;
130
LbxFindExtension(char *extname,
135
for (i = 0; i < num_exts; i++) {
136
if ((strlen(lbx_extensions[i]->name) == len) &&
137
(strncmp(lbx_extensions[i]->name, extname, len) == 0))
139
for (j = lbx_extensions[i]->num_aliases; --j >= 0;) {
140
if ((strlen(lbx_extensions[i]->aliases[j]) == len) &&
141
(strncmp(lbx_extensions[i]->aliases[j], extname, len) == 0))
149
LbxDeclareExtensionSecurity(char *extname,
153
int i = LbxFindExtension(extname, strlen(extname));
155
lbx_extensions[i]->secure = secure;
160
LbxRegisterExtensionGenerationMasks(int idx,
165
LbxExtensionEntry *ext = lbx_extensions[idx];
168
int mlen = mlen = num_reqs / (8 * sizeof(CARD8)) + 1;
170
nrm = (CARD8 *) xalloc(sizeof(CARD8) * mlen);
171
nem = (CARD8 *) xalloc(sizeof(CARD8) * mlen);
178
memcpy((char *) nrm, (char *) rep_mask, mlen);
179
memcpy((char *) nem, (char *) ev_mask, mlen);
182
ext->num_reqs = num_reqs;
188
LbxQueryExtension(ClientPtr client,
192
xLbxQueryExtensionReply rep;
197
rep.sequenceNumber = client->sequence;
198
rep.major_opcode = 0;
201
rep.pad0 = rep.pad1 = rep.pad2 = rep.pad3 = rep.pad4 = 0;
203
i = LbxFindExtension(ename, nlen);
207
/* don't show insecure extensions to untrusted clients */
208
|| (client->trustLevel == XSecurityClientUntrusted &&
209
!lbx_extensions[i]->secure)
215
rep.major_opcode = lbx_extensions[i]->opcode;
216
rep.first_event = lbx_extensions[i]->ev_base;
217
rep.first_error = lbx_extensions[i]->err_base;
218
rep.numReqs = lbx_extensions[i]->num_reqs;
219
if (lbx_extensions[i]->rep_mask) {
220
mlen = (lbx_extensions[i]->num_reqs + 7) >> 3;
221
rep.length = ((mlen + 3) >> 2) * 2;
224
if (client->swapped) {
227
swaps(&rep.sequenceNumber, n);
228
swapl(&rep.length, n);
230
WriteToClient(client, sizeof(xLbxQueryExtensionReply), (char *)&rep);
232
WriteToClient(client, mlen, (char *)lbx_extensions[i]->rep_mask);
233
WriteToClient(client, mlen, (char *)lbx_extensions[i]->ev_mask);
239
LbxCloseDownExtensions(void)
243
for (i = 0; i < num_exts; i++) {
244
xfree(lbx_extensions[i]->name);
245
for (j = 0; j < lbx_extensions[i]->num_aliases; j++)
246
xfree(lbx_extensions[i]->aliases[j]);
247
xfree(lbx_extensions[i]->aliases);
248
xfree(lbx_extensions[i]->rep_mask);
249
xfree(lbx_extensions[i]->ev_mask);
250
xfree(lbx_extensions[i]);
252
xfree(lbx_extensions);
253
lbx_extensions = NULL;
259
LbxSetReqMask(CARD8 *mask,
263
int mword = req / (8 * sizeof(CARD8));
265
req = req % (8 * sizeof(CARD8));
267
mask[mword] |= (1 << req);
269
mask[mword] &= ~(1 << req);