]> git.sesse.net Git - rdpsrv/blob - Xserver/programs/Xserver/Xext/mitmisc.c
Import X server from vnc-3.3.7.
[rdpsrv] / Xserver / programs / Xserver / Xext / mitmisc.c
1 /************************************************************
2
3 Copyright (c) 1989  X Consortium
4
5 Permission is hereby granted, free of charge, to any person obtaining a copy
6 of this software and associated documentation files (the "Software"), to deal
7 in the Software without restriction, including without limitation the rights
8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 copies of the Software, and to permit persons to whom the Software is
10 furnished to do so, subject to the following conditions:
11
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
14
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
18 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22 Except as contained in this notice, the name of the X Consortium shall not be
23 used in advertising or otherwise to promote the sale, use or other dealings
24 in this Software without prior written authorization from the X Consortium.
25
26 ********************************************************/
27
28 /* RANDOM CRUFT! THIS HAS NO OFFICIAL X CONSORTIUM BLESSING */
29
30 /* $XConsortium: mitmisc.c,v 1.5 94/04/17 20:32:54 rws Exp $ */
31 /* $XFree86: xc/programs/Xserver/Xext/mitmisc.c,v 3.1 1996/05/06 05:55:29 dawes Exp $ */
32
33 #define NEED_EVENTS
34 #include "X.h"
35 #include "Xproto.h"
36 #include "misc.h"
37 #include "os.h"
38 #include "dixstruct.h"
39 #include "extnsionst.h"
40 #define _MITMISC_SERVER_
41 #include "mitmiscstr.h"
42
43 extern Bool permitOldBugs;
44
45 static unsigned char MITReqCode;
46
47 static void MITResetProc(
48 #if NeedFunctionPrototypes
49     ExtensionEntry * /* extEntry */
50 #endif
51 );
52
53 static DISPATCH_PROC(ProcMITDispatch);
54 static DISPATCH_PROC(ProcMITGetBugMode);
55 static DISPATCH_PROC(ProcMITSetBugMode);
56 static DISPATCH_PROC(SProcMITDispatch);
57 static DISPATCH_PROC(SProcMITGetBugMode);
58 static DISPATCH_PROC(SProcMITSetBugMode);
59
60 void
61 MITMiscExtensionInit()
62 {
63     ExtensionEntry *extEntry;
64
65     if ((extEntry = AddExtension(MITMISCNAME, 0, 0,
66                                  ProcMITDispatch, SProcMITDispatch,
67                                  MITResetProc, StandardMinorOpcode)) != 0)
68         MITReqCode = (unsigned char)extEntry->base;
69 }
70
71 /*ARGSUSED*/
72 static void
73 MITResetProc (extEntry)
74 ExtensionEntry  *extEntry;
75 {
76 }
77
78 static int
79 ProcMITSetBugMode(client)
80     register ClientPtr client;
81 {
82     REQUEST(xMITSetBugModeReq);
83
84     REQUEST_SIZE_MATCH(xMITSetBugModeReq);
85     if ((stuff->onOff != xTrue) && (stuff->onOff != xFalse))
86     {
87         client->errorValue = stuff->onOff;
88         return BadValue;
89     }
90     permitOldBugs = stuff->onOff;
91     return(client->noClientException);
92 }
93
94 static int
95 ProcMITGetBugMode(client)
96     register ClientPtr client;
97 {
98     xMITGetBugModeReply rep;
99     register int n;
100
101     REQUEST_SIZE_MATCH(xMITGetBugModeReq);
102     rep.type = X_Reply;
103     rep.length = 0;
104     rep.sequenceNumber = client->sequence;
105     rep.onOff = permitOldBugs;
106     if (client->swapped) {
107         swaps(&rep.sequenceNumber, n);
108         swapl(&rep.length, n);
109     }
110     WriteToClient(client, sizeof(xMITGetBugModeReply), (char *)&rep);
111     return(client->noClientException);
112 }
113
114 static int
115 ProcMITDispatch (client)
116     register ClientPtr  client;
117 {
118     REQUEST(xReq);
119     switch (stuff->data)
120     {
121     case X_MITSetBugMode:
122         return ProcMITSetBugMode(client);
123     case X_MITGetBugMode:
124         return ProcMITGetBugMode(client);
125     default:
126         return BadRequest;
127     }
128 }
129
130 static int
131 SProcMITSetBugMode(client)
132     register ClientPtr  client;
133 {
134     register int n;
135     REQUEST(xMITSetBugModeReq);
136
137     swaps(&stuff->length, n);
138     return ProcMITSetBugMode(client);
139 }
140
141 static int
142 SProcMITGetBugMode(client)
143     register ClientPtr  client;
144 {
145     register int n;
146     REQUEST(xMITGetBugModeReq);
147
148     swaps(&stuff->length, n);
149     return ProcMITGetBugMode(client);
150 }
151
152 static int
153 SProcMITDispatch (client)
154     register ClientPtr  client;
155 {
156     REQUEST(xReq);
157     switch (stuff->data)
158     {
159     case X_MITSetBugMode:
160         return SProcMITSetBugMode(client);
161     case X_MITGetBugMode:
162         return SProcMITGetBugMode(client);
163     default:
164         return BadRequest;
165     }
166 }