3 Copyright 1993, 1998 The Open Group
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
11 The above copyright notice and this permission notice shall be included
12 in all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 OTHER DEALINGS IN THE SOFTWARE.
22 Except as contained in this notice, the name of The Open Group shall
23 not be used in advertising or otherwise to promote the sale, use or
24 other dealings in this Software without prior written authorization
29 #ifdef HAVE_DIX_CONFIG_H
30 #include <dix-config.h>
34 #include <X11/Xproto.h>
37 #include "dixstruct.h"
38 #include "extnsionst.h"
40 #include <X11/extensions/xcmiscproto.h>
46 ProcXCMiscGetVersion(ClientPtr client
)
48 xXCMiscGetVersionReply rep
= {
50 .sequenceNumber
= client
->sequence
,
52 .majorVersion
= XCMiscMajorVersion
,
53 .minorVersion
= XCMiscMinorVersion
56 REQUEST_SIZE_MATCH(xXCMiscGetVersionReq
);
58 if (client
->swapped
) {
59 swaps(&rep
.sequenceNumber
);
60 swaps(&rep
.majorVersion
);
61 swaps(&rep
.minorVersion
);
63 WriteToClient(client
, sizeof(xXCMiscGetVersionReply
), &rep
);
68 ProcXCMiscGetXIDRange(ClientPtr client
)
70 xXCMiscGetXIDRangeReply rep
;
73 REQUEST_SIZE_MATCH(xXCMiscGetXIDRangeReq
);
74 GetXIDRange(client
->index
, FALSE
, &min_id
, &max_id
);
75 rep
= (xXCMiscGetXIDRangeReply
) {
77 .sequenceNumber
= client
->sequence
,
80 .count
= max_id
- min_id
+ 1
82 if (client
->swapped
) {
83 swaps(&rep
.sequenceNumber
);
87 WriteToClient(client
, sizeof(xXCMiscGetXIDRangeReply
), &rep
);
92 ProcXCMiscGetXIDList(ClientPtr client
)
94 REQUEST(xXCMiscGetXIDListReq
);
95 xXCMiscGetXIDListReply rep
;
99 REQUEST_SIZE_MATCH(xXCMiscGetXIDListReq
);
101 if (stuff
->count
> UINT32_MAX
/ sizeof(XID
))
104 pids
= (XID
*) malloc(stuff
->count
* sizeof(XID
));
108 count
= GetXIDList(client
, stuff
->count
, pids
);
109 rep
= (xXCMiscGetXIDListReply
) {
111 .sequenceNumber
= client
->sequence
,
115 if (client
->swapped
) {
116 swaps(&rep
.sequenceNumber
);
120 WriteToClient(client
, sizeof(xXCMiscGetXIDListReply
), &rep
);
122 client
->pSwapReplyFunc
= (ReplySwapPtr
) Swap32Write
;
123 WriteSwappedDataToClient(client
, count
* sizeof(XID
), pids
);
130 ProcXCMiscDispatch(ClientPtr client
)
133 switch (stuff
->data
) {
134 case X_XCMiscGetVersion
:
135 return ProcXCMiscGetVersion(client
);
136 case X_XCMiscGetXIDRange
:
137 return ProcXCMiscGetXIDRange(client
);
138 case X_XCMiscGetXIDList
:
139 return ProcXCMiscGetXIDList(client
);
146 SProcXCMiscGetVersion(ClientPtr client
)
148 REQUEST(xXCMiscGetVersionReq
);
150 swaps(&stuff
->length
);
151 REQUEST_SIZE_MATCH(xXCMiscGetVersionReq
);
152 swaps(&stuff
->majorVersion
);
153 swaps(&stuff
->minorVersion
);
154 return ProcXCMiscGetVersion(client
);
158 SProcXCMiscGetXIDRange(ClientPtr client
)
162 swaps(&stuff
->length
);
163 return ProcXCMiscGetXIDRange(client
);
167 SProcXCMiscGetXIDList(ClientPtr client
)
169 REQUEST(xXCMiscGetXIDListReq
);
171 swaps(&stuff
->length
);
172 swapl(&stuff
->count
);
173 return ProcXCMiscGetXIDList(client
);
177 SProcXCMiscDispatch(ClientPtr client
)
180 switch (stuff
->data
) {
181 case X_XCMiscGetVersion
:
182 return SProcXCMiscGetVersion(client
);
183 case X_XCMiscGetXIDRange
:
184 return SProcXCMiscGetXIDRange(client
);
185 case X_XCMiscGetXIDList
:
186 return SProcXCMiscGetXIDList(client
);
193 XCMiscExtensionInit(void)
195 AddExtension(XCMiscExtensionName
, 0, 0,
196 ProcXCMiscDispatch
, SProcXCMiscDispatch
,
197 NULL
, StandardMinorOpcode
);