1 /* $XConsortium: xcmisc.c /main/5 1996/08/01 19:23:23 dpw $ */
2 /* $XFree86: xc/programs/Xserver/Xext/xcmisc.c,v 3.2 1996/12/23 06:29:03 dawes Exp $ */
5 Copyright (c) 1993 X Consortium
7 Permission is hereby granted, free of charge, to any person obtaining
8 a copy of this software and associated documentation files (the
9 "Software"), to deal in the Software without restriction, including
10 without limitation the rights to use, copy, modify, merge, publish,
11 distribute, sublicense, and/or sell copies of the Software, and to
12 permit persons to whom the Software is furnished to do so, subject to
13 the following conditions:
15 The above copyright notice and this permission notice shall be included
16 in all copies or substantial portions of the Software.
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
22 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 OTHER DEALINGS IN THE SOFTWARE.
26 Except as contained in this notice, the name of the X Consortium shall
27 not be used in advertising or otherwise to promote the sale, use or
28 other dealings in this Software without prior written authorization
29 from the X Consortium.
39 #include "dixstruct.h"
40 #include "extnsionst.h"
42 #include "xcmiscstr.h"
44 static unsigned char XCMiscCode;
46 static void XCMiscResetProc(
47 #if NeedFunctionPrototypes
48 ExtensionEntry * /* extEntry */
52 static DISPATCH_PROC(ProcXCMiscDispatch);
53 static DISPATCH_PROC(ProcXCMiscGetVersion);
54 static DISPATCH_PROC(ProcXCMiscGetXIDList);
55 static DISPATCH_PROC(ProcXCMiscGetXIDRange);
56 static DISPATCH_PROC(SProcXCMiscDispatch);
57 static DISPATCH_PROC(SProcXCMiscGetVersion);
58 static DISPATCH_PROC(SProcXCMiscGetXIDList);
59 static DISPATCH_PROC(SProcXCMiscGetXIDRange);
64 ExtensionEntry *extEntry;
66 if ((extEntry = AddExtension(XCMiscExtensionName, 0, 0,
67 ProcXCMiscDispatch, SProcXCMiscDispatch,
68 XCMiscResetProc, StandardMinorOpcode)) != 0)
69 XCMiscCode = (unsigned char)extEntry->base;
70 DeclareExtensionSecurity(XCMiscExtensionName, TRUE);
75 XCMiscResetProc (extEntry)
76 ExtensionEntry *extEntry;
81 ProcXCMiscGetVersion(client)
82 register ClientPtr client;
84 xXCMiscGetVersionReply rep;
87 REQUEST_SIZE_MATCH(xXCMiscGetVersionReq);
90 rep.sequenceNumber = client->sequence;
91 rep.majorVersion = XCMiscMajorVersion;
92 rep.minorVersion = XCMiscMinorVersion;
93 if (client->swapped) {
94 swaps(&rep.sequenceNumber, n);
95 swaps(&rep.majorVersion, n);
96 swaps(&rep.minorVersion, n);
98 WriteToClient(client, sizeof(xXCMiscGetVersionReply), (char *)&rep);
99 return(client->noClientException);
103 ProcXCMiscGetXIDRange(client)
104 register ClientPtr client;
106 xXCMiscGetXIDRangeReply rep;
110 REQUEST_SIZE_MATCH(xXCMiscGetXIDRangeReq);
111 GetXIDRange(client->index, FALSE, &min_id, &max_id);
114 rep.sequenceNumber = client->sequence;
115 rep.start_id = min_id;
116 rep.count = max_id - min_id + 1;
117 if (client->swapped) {
118 swaps(&rep.sequenceNumber, n);
119 swapl(&rep.start_id, n);
120 swapl(&rep.count, n);
122 WriteToClient(client, sizeof(xXCMiscGetXIDRangeReply), (char *)&rep);
123 return(client->noClientException);
127 ProcXCMiscGetXIDList(client)
128 register ClientPtr client;
130 REQUEST(xXCMiscGetXIDListReq);
131 xXCMiscGetXIDListReply rep;
136 REQUEST_SIZE_MATCH(xXCMiscGetXIDListReq);
138 pids = (XID *)ALLOCATE_LOCAL(stuff->count * sizeof(XID));
143 count = GetXIDList(client, stuff->count, pids);
145 rep.sequenceNumber = client->sequence;
148 if (client->swapped) {
149 swaps(&rep.sequenceNumber, n);
150 swapl(&rep.length, n);
151 swapl(&rep.count, n);
153 WriteToClient(client, sizeof(xXCMiscGetXIDListReply), (char *)&rep);
156 client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
157 WriteSwappedDataToClient(client, count * sizeof(XID), pids);
159 DEALLOCATE_LOCAL(pids);
160 return(client->noClientException);
164 ProcXCMiscDispatch (client)
165 register ClientPtr client;
170 case X_XCMiscGetVersion:
171 return ProcXCMiscGetVersion(client);
172 case X_XCMiscGetXIDRange:
173 return ProcXCMiscGetXIDRange(client);
174 case X_XCMiscGetXIDList:
175 return ProcXCMiscGetXIDList(client);
182 SProcXCMiscGetVersion(client)
183 register ClientPtr client;
186 REQUEST(xXCMiscGetVersionReq);
188 swaps(&stuff->length, n);
189 REQUEST_SIZE_MATCH(xXCMiscGetVersionReq);
190 swaps(&stuff->majorVersion, n);
191 swaps(&stuff->minorVersion, n);
192 return ProcXCMiscGetVersion(client);
196 SProcXCMiscGetXIDRange(client)
197 register ClientPtr client;
202 swaps(&stuff->length, n);
203 return ProcXCMiscGetXIDRange(client);
207 SProcXCMiscGetXIDList(client)
208 register ClientPtr client;
211 REQUEST(xXCMiscGetXIDListReq);
213 swaps(&stuff->length, n);
214 swapl(&stuff->count, n);
215 return ProcXCMiscGetXIDList(client);
219 SProcXCMiscDispatch (client)
220 register ClientPtr client;
225 case X_XCMiscGetVersion:
226 return SProcXCMiscGetVersion(client);
227 case X_XCMiscGetXIDRange:
228 return SProcXCMiscGetXIDRange(client);
229 case X_XCMiscGetXIDList:
230 return SProcXCMiscGetXIDList(client);