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 #include <dix-config.h>
32 #include <X11/Xproto.h>
35 #include "dixstruct.h"
36 #include "extnsionst.h"
38 #include <X11/extensions/xcmiscproto.h>
39 #include "extinit_priv.h"
44 ProcXCMiscGetVersion(ClientPtr client
)
46 xXCMiscGetVersionReply rep
= {
48 .sequenceNumber
= client
->sequence
,
50 .majorVersion
= XCMiscMajorVersion
,
51 .minorVersion
= XCMiscMinorVersion
54 REQUEST_SIZE_MATCH(xXCMiscGetVersionReq
);
56 if (client
->swapped
) {
57 swaps(&rep
.sequenceNumber
);
58 swaps(&rep
.majorVersion
);
59 swaps(&rep
.minorVersion
);
61 WriteToClient(client
, sizeof(xXCMiscGetVersionReply
), &rep
);
66 ProcXCMiscGetXIDRange(ClientPtr client
)
68 xXCMiscGetXIDRangeReply rep
;
71 REQUEST_SIZE_MATCH(xXCMiscGetXIDRangeReq
);
72 GetXIDRange(client
->index
, FALSE
, &min_id
, &max_id
);
73 rep
= (xXCMiscGetXIDRangeReply
) {
75 .sequenceNumber
= client
->sequence
,
78 .count
= max_id
- min_id
+ 1
80 if (client
->swapped
) {
81 swaps(&rep
.sequenceNumber
);
85 WriteToClient(client
, sizeof(xXCMiscGetXIDRangeReply
), &rep
);
90 ProcXCMiscGetXIDList(ClientPtr client
)
92 REQUEST(xXCMiscGetXIDListReq
);
93 xXCMiscGetXIDListReply rep
;
97 REQUEST_SIZE_MATCH(xXCMiscGetXIDListReq
);
99 if (stuff
->count
> UINT32_MAX
/ sizeof(XID
))
102 pids
= xallocarray(stuff
->count
, sizeof(XID
));
106 count
= GetXIDList(client
, stuff
->count
, pids
);
107 rep
= (xXCMiscGetXIDListReply
) {
109 .sequenceNumber
= client
->sequence
,
113 if (client
->swapped
) {
114 swaps(&rep
.sequenceNumber
);
118 WriteToClient(client
, sizeof(xXCMiscGetXIDListReply
), &rep
);
120 client
->pSwapReplyFunc
= (ReplySwapPtr
) Swap32Write
;
121 WriteSwappedDataToClient(client
, count
* sizeof(XID
), pids
);
128 ProcXCMiscDispatch(ClientPtr client
)
131 switch (stuff
->data
) {
132 case X_XCMiscGetVersion
:
133 return ProcXCMiscGetVersion(client
);
134 case X_XCMiscGetXIDRange
:
135 return ProcXCMiscGetXIDRange(client
);
136 case X_XCMiscGetXIDList
:
137 return ProcXCMiscGetXIDList(client
);
144 SProcXCMiscGetVersion(ClientPtr client
)
146 REQUEST(xXCMiscGetVersionReq
);
148 swaps(&stuff
->length
);
149 REQUEST_SIZE_MATCH(xXCMiscGetVersionReq
);
150 swaps(&stuff
->majorVersion
);
151 swaps(&stuff
->minorVersion
);
152 return ProcXCMiscGetVersion(client
);
156 SProcXCMiscGetXIDRange(ClientPtr client
)
160 swaps(&stuff
->length
);
161 return ProcXCMiscGetXIDRange(client
);
165 SProcXCMiscGetXIDList(ClientPtr client
)
167 REQUEST(xXCMiscGetXIDListReq
);
168 REQUEST_SIZE_MATCH(xXCMiscGetXIDListReq
);
170 swaps(&stuff
->length
);
171 swapl(&stuff
->count
);
172 return ProcXCMiscGetXIDList(client
);
176 SProcXCMiscDispatch(ClientPtr client
)
179 switch (stuff
->data
) {
180 case X_XCMiscGetVersion
:
181 return SProcXCMiscGetVersion(client
);
182 case X_XCMiscGetXIDRange
:
183 return SProcXCMiscGetXIDRange(client
);
184 case X_XCMiscGetXIDList
:
185 return SProcXCMiscGetXIDList(client
);
192 XCMiscExtensionInit(void)
194 AddExtension(XCMiscExtensionName
, 0, 0,
195 ProcXCMiscDispatch
, SProcXCMiscDispatch
,
196 NULL
, StandardMinorOpcode
);