1 | /* $XFree86: xc/programs/Xserver/os/osdep.h,v 3.17 2002/05/31 18:46:06 dawes Exp $ */
|
---|
2 | /***********************************************************
|
---|
3 |
|
---|
4 | Copyright 1987, 1998 The Open Group
|
---|
5 |
|
---|
6 | Permission to use, copy, modify, distribute, and sell this software and its
|
---|
7 | documentation for any purpose is hereby granted without fee, provided that
|
---|
8 | the above copyright notice appear in all copies and that both that
|
---|
9 | copyright notice and this permission notice appear in supporting
|
---|
10 | documentation.
|
---|
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 | OPEN GROUP 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 Open Group 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 Open Group.
|
---|
25 |
|
---|
26 |
|
---|
27 | Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
|
---|
28 |
|
---|
29 | All Rights Reserved
|
---|
30 |
|
---|
31 | Permission to use, copy, modify, and distribute this software and its
|
---|
32 | documentation for any purpose and without fee is hereby granted,
|
---|
33 | provided that the above copyright notice appear in all copies and that
|
---|
34 | both that copyright notice and this permission notice appear in
|
---|
35 | supporting documentation, and that the name of Digital not be
|
---|
36 | used in advertising or publicity pertaining to distribution of the
|
---|
37 | software without specific, written prior permission.
|
---|
38 |
|
---|
39 | DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
---|
40 | ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
---|
41 | DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
---|
42 | ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
---|
43 | WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
---|
44 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
---|
45 | SOFTWARE.
|
---|
46 |
|
---|
47 | ******************************************************************/
|
---|
48 | /* $Xorg: osdep.h,v 1.5 2001/02/09 02:05:23 xorgcvs Exp $ */
|
---|
49 |
|
---|
50 | #ifdef HAVE_DIX_CONFIG_H
|
---|
51 | #include <dix-config.h>
|
---|
52 | #endif
|
---|
53 |
|
---|
54 | #ifndef _OSDEP_H_
|
---|
55 | #define _OSDEP_H_ 1
|
---|
56 |
|
---|
57 | #define BOTIMEOUT 200 /* in milliseconds */
|
---|
58 | #define BUFSIZE 4096
|
---|
59 | #define BUFWATERMARK 8192
|
---|
60 | #ifndef MAXBUFSIZE
|
---|
61 | #define MAXBUFSIZE (1 << 22)
|
---|
62 | #endif
|
---|
63 |
|
---|
64 | #include <X11/Xdmcp.h>
|
---|
65 |
|
---|
66 | #ifndef sgi /* SGI defines OPEN_MAX in a useless way */
|
---|
67 | #ifndef X_NOT_POSIX
|
---|
68 | #ifdef _POSIX_SOURCE
|
---|
69 | #include <limits.h>
|
---|
70 | #else
|
---|
71 | #define _POSIX_SOURCE
|
---|
72 | #include <limits.h>
|
---|
73 | #undef _POSIX_SOURCE
|
---|
74 | #endif
|
---|
75 | #else /* X_NOT_POSIX */
|
---|
76 | #ifdef WIN32
|
---|
77 | #define _POSIX_
|
---|
78 | #include <limits.h>
|
---|
79 | #undef _POSIX_
|
---|
80 | #endif
|
---|
81 | #endif /* X_NOT_POSIX */
|
---|
82 | #endif
|
---|
83 |
|
---|
84 | #ifdef __QNX__
|
---|
85 | #define NOFILES_MAX 256
|
---|
86 | #endif
|
---|
87 | #ifndef OPEN_MAX
|
---|
88 | #ifdef SVR4
|
---|
89 | #define OPEN_MAX 256
|
---|
90 | #else
|
---|
91 | #include <sys/param.h>
|
---|
92 | #ifndef OPEN_MAX
|
---|
93 | #if defined(NOFILE) && !defined(NOFILES_MAX)
|
---|
94 | #define OPEN_MAX NOFILE
|
---|
95 | #else
|
---|
96 | #if !defined(__UNIXOS2__) && !defined(WIN32)
|
---|
97 | #define OPEN_MAX NOFILES_MAX
|
---|
98 | #else
|
---|
99 | #define OPEN_MAX 256
|
---|
100 | #endif
|
---|
101 | #endif
|
---|
102 | #endif
|
---|
103 | #endif
|
---|
104 | #endif
|
---|
105 |
|
---|
106 | #include <X11/Xpoll.h>
|
---|
107 |
|
---|
108 | /*
|
---|
109 | * MAXSOCKS is used only for initialising MaxClients when no other method
|
---|
110 | * like sysconf(_SC_OPEN_MAX) is not supported.
|
---|
111 | */
|
---|
112 |
|
---|
113 | #if OPEN_MAX <= 256
|
---|
114 | #define MAXSOCKS (OPEN_MAX - 1)
|
---|
115 | #else
|
---|
116 | #define MAXSOCKS 256
|
---|
117 | #endif
|
---|
118 |
|
---|
119 | /* MAXSELECT is the number of fds that select() can handle */
|
---|
120 | #define MAXSELECT (sizeof(fd_set) * NBBY)
|
---|
121 |
|
---|
122 | #ifndef HAS_GETDTABLESIZE
|
---|
123 | #if !defined(hpux) && !defined(SVR4) && !defined(SYSV)
|
---|
124 | #define HAS_GETDTABLESIZE
|
---|
125 | #endif
|
---|
126 | #endif
|
---|
127 |
|
---|
128 | #include <stddef.h>
|
---|
129 |
|
---|
130 | typedef Bool (*ValidatorFunc)(ARRAY8Ptr Auth, ARRAY8Ptr Data, int packet_type);
|
---|
131 | typedef Bool (*GeneratorFunc)(ARRAY8Ptr Auth, ARRAY8Ptr Data, int packet_type);
|
---|
132 | typedef Bool (*AddAuthorFunc)(unsigned name_length, char *name, unsigned data_length, char *data);
|
---|
133 |
|
---|
134 | typedef struct _connectionInput {
|
---|
135 | struct _connectionInput *next;
|
---|
136 | char *buffer; /* contains current client input */
|
---|
137 | char *bufptr; /* pointer to current start of data */
|
---|
138 | int bufcnt; /* count of bytes in buffer */
|
---|
139 | int lenLastReq;
|
---|
140 | int size;
|
---|
141 | } ConnectionInput, *ConnectionInputPtr;
|
---|
142 |
|
---|
143 | typedef struct _connectionOutput {
|
---|
144 | struct _connectionOutput *next;
|
---|
145 | int size;
|
---|
146 | unsigned char *buf;
|
---|
147 | int count;
|
---|
148 | #ifdef LBX
|
---|
149 | Bool nocompress;
|
---|
150 | #endif
|
---|
151 | } ConnectionOutput, *ConnectionOutputPtr;
|
---|
152 |
|
---|
153 | #ifdef K5AUTH
|
---|
154 | typedef struct _k5_state {
|
---|
155 | int stageno; /* current stage of auth protocol */
|
---|
156 | pointer srvcreds; /* server credentials */
|
---|
157 | pointer srvname; /* server principal name */
|
---|
158 | pointer ktname; /* key table: principal-key pairs */
|
---|
159 | pointer skey; /* session key */
|
---|
160 | } k5_state;
|
---|
161 | #endif
|
---|
162 |
|
---|
163 | #ifdef LBX
|
---|
164 | typedef struct _LbxProxy *OsProxyPtr;
|
---|
165 | #endif
|
---|
166 |
|
---|
167 | struct _osComm;
|
---|
168 |
|
---|
169 | #define AuthInitArgs void
|
---|
170 | typedef void (*AuthInitFunc) (AuthInitArgs);
|
---|
171 |
|
---|
172 | #define AuthAddCArgs unsigned short data_length, char *data, XID id
|
---|
173 | typedef int (*AuthAddCFunc) (AuthAddCArgs);
|
---|
174 |
|
---|
175 | #define AuthCheckArgs unsigned short data_length, char *data, ClientPtr client, char **reason
|
---|
176 | typedef XID (*AuthCheckFunc) (AuthCheckArgs);
|
---|
177 |
|
---|
178 | #define AuthFromIDArgs XID id, unsigned short *data_lenp, char **datap
|
---|
179 | typedef int (*AuthFromIDFunc) (AuthFromIDArgs);
|
---|
180 |
|
---|
181 | #define AuthGenCArgs unsigned data_length, char *data, XID id, unsigned *data_length_return, char **data_return
|
---|
182 | typedef XID (*AuthGenCFunc) (AuthGenCArgs);
|
---|
183 |
|
---|
184 | #define AuthRemCArgs unsigned short data_length, char *data
|
---|
185 | typedef int (*AuthRemCFunc) (AuthRemCArgs);
|
---|
186 |
|
---|
187 | #define AuthRstCArgs void
|
---|
188 | typedef int (*AuthRstCFunc) (AuthRstCArgs);
|
---|
189 |
|
---|
190 | #define AuthToIDArgs unsigned short data_length, char *data
|
---|
191 | typedef XID (*AuthToIDFunc) (AuthToIDArgs);
|
---|
192 |
|
---|
193 | typedef void (*OsCloseFunc)(ClientPtr);
|
---|
194 |
|
---|
195 | typedef int (*OsFlushFunc)(ClientPtr who, struct _osComm * oc, char* extraBuf, int extraCount);
|
---|
196 |
|
---|
197 | typedef struct _osComm {
|
---|
198 | int fd;
|
---|
199 | ConnectionInputPtr input;
|
---|
200 | ConnectionOutputPtr output;
|
---|
201 | XID auth_id; /* authorization id */
|
---|
202 | #ifdef K5AUTH
|
---|
203 | k5_state authstate; /* state of setup auth conversation */
|
---|
204 | #endif
|
---|
205 | CARD32 conn_time; /* timestamp if not established, else 0 */
|
---|
206 | struct _XtransConnInfo *trans_conn; /* transport connection object */
|
---|
207 | #ifdef LBX
|
---|
208 | OsProxyPtr proxy;
|
---|
209 | ConnectionInputPtr largereq;
|
---|
210 | OsCloseFunc Close;
|
---|
211 | OsFlushFunc Flush;
|
---|
212 | #endif
|
---|
213 | } OsCommRec, *OsCommPtr;
|
---|
214 |
|
---|
215 | #ifdef LBX
|
---|
216 | #define FlushClient(who, oc, extraBuf, extraCount) \
|
---|
217 | (*(oc)->Flush)(who, oc, extraBuf, extraCount)
|
---|
218 | extern int StandardFlushClient(
|
---|
219 | ClientPtr /*who*/,
|
---|
220 | OsCommPtr /*oc*/,
|
---|
221 | char* /*extraBuf*/,
|
---|
222 | int /*extraCount*/
|
---|
223 | );
|
---|
224 | extern int LbxFlushClient(ClientPtr /*who*/, OsCommPtr /*oc*/,
|
---|
225 | char * /*extraBuf*/, int /*extraCount*/);
|
---|
226 | #else
|
---|
227 | extern int FlushClient(
|
---|
228 | ClientPtr /*who*/,
|
---|
229 | OsCommPtr /*oc*/,
|
---|
230 | char* /*extraBuf*/,
|
---|
231 | int /*extraCount*/
|
---|
232 | );
|
---|
233 | #endif
|
---|
234 |
|
---|
235 | extern void FreeOsBuffers(
|
---|
236 | OsCommPtr /*oc*/
|
---|
237 | );
|
---|
238 |
|
---|
239 | #include "dix.h"
|
---|
240 |
|
---|
241 | extern ConnectionInputPtr AllocateInputBuffer(void);
|
---|
242 |
|
---|
243 | extern ConnectionOutputPtr AllocateOutputBuffer(void);
|
---|
244 |
|
---|
245 | extern fd_set AllSockets;
|
---|
246 | extern fd_set AllClients;
|
---|
247 | extern fd_set LastSelectMask;
|
---|
248 | extern fd_set WellKnownConnections;
|
---|
249 | extern fd_set EnabledDevices;
|
---|
250 | extern fd_set ClientsWithInput;
|
---|
251 | extern fd_set ClientsWriteBlocked;
|
---|
252 | extern fd_set OutputPending;
|
---|
253 | extern fd_set IgnoredClientsWithInput;
|
---|
254 |
|
---|
255 | #ifndef WIN32
|
---|
256 | extern int *ConnectionTranslation;
|
---|
257 | #else
|
---|
258 | extern int GetConnectionTranslation(int conn);
|
---|
259 | extern void SetConnectionTranslation(int conn, int client);
|
---|
260 | extern void ClearConnectionTranslation();
|
---|
261 | #endif
|
---|
262 |
|
---|
263 | extern Bool NewOutputPending;
|
---|
264 | extern Bool AnyClientsWriteBlocked;
|
---|
265 | extern Bool CriticalOutputPending;
|
---|
266 |
|
---|
267 | extern int timesThisConnection;
|
---|
268 | extern ConnectionInputPtr FreeInputs;
|
---|
269 | extern ConnectionOutputPtr FreeOutputs;
|
---|
270 | extern OsCommPtr AvailableInput;
|
---|
271 |
|
---|
272 | extern WorkQueuePtr workQueue;
|
---|
273 |
|
---|
274 | /* added by raphael */
|
---|
275 | #ifdef WIN32
|
---|
276 | typedef long int fd_mask;
|
---|
277 | #endif
|
---|
278 | #define ffs mffs
|
---|
279 | extern int mffs(fd_mask);
|
---|
280 |
|
---|
281 | /* in auth.c */
|
---|
282 | extern void GenerateRandomData (int len, char *buf);
|
---|
283 |
|
---|
284 | /* in mitauth.c */
|
---|
285 | extern XID MitCheckCookie (AuthCheckArgs);
|
---|
286 | extern XID MitGenerateCookie (AuthGenCArgs);
|
---|
287 | extern XID MitToID (AuthToIDArgs);
|
---|
288 | extern int MitAddCookie (AuthAddCArgs);
|
---|
289 | extern int MitFromID (AuthFromIDArgs);
|
---|
290 | extern int MitRemoveCookie (AuthRemCArgs);
|
---|
291 | extern int MitResetCookie (AuthRstCArgs);
|
---|
292 |
|
---|
293 | /* in xdmauth.c */
|
---|
294 | #ifdef HASXDMAUTH
|
---|
295 | extern XID XdmCheckCookie (AuthCheckArgs);
|
---|
296 | extern XID XdmToID (AuthToIDArgs);
|
---|
297 | extern int XdmAddCookie (AuthAddCArgs);
|
---|
298 | extern int XdmFromID (AuthFromIDArgs);
|
---|
299 | extern int XdmRemoveCookie (AuthRemCArgs);
|
---|
300 | extern int XdmResetCookie (AuthRstCArgs);
|
---|
301 | #endif
|
---|
302 |
|
---|
303 | /* in rpcauth.c */
|
---|
304 | #ifdef SECURE_RPC
|
---|
305 | extern void SecureRPCInit (AuthInitArgs);
|
---|
306 | extern XID SecureRPCCheck (AuthCheckArgs);
|
---|
307 | extern XID SecureRPCToID (AuthToIDArgs);
|
---|
308 | extern int SecureRPCAdd (AuthAddCArgs);
|
---|
309 | extern int SecureRPCFromID (AuthFromIDArgs);
|
---|
310 | extern int SecureRPCRemove (AuthRemCArgs);
|
---|
311 | extern int SecureRPCReset (AuthRstCArgs);
|
---|
312 | #endif
|
---|
313 |
|
---|
314 | /* in k5auth.c */
|
---|
315 | #ifdef K5AUTH
|
---|
316 | extern XID K5Check (AuthCheckArgs);
|
---|
317 | extern XID K5ToID (AuthToIDArgs);
|
---|
318 | extern int K5Add (AuthAddCArgs);
|
---|
319 | extern int K5FromID (AuthFromIDArgs);
|
---|
320 | extern int K5Remove (AuthRemCArgs);
|
---|
321 | extern int K5Reset (AuthRstCArgs);
|
---|
322 | #endif
|
---|
323 |
|
---|
324 | /* in secauth.c */
|
---|
325 | extern XID AuthSecurityCheck (AuthCheckArgs);
|
---|
326 |
|
---|
327 | /* in xdmcp.c */
|
---|
328 | extern void XdmcpUseMsg (void);
|
---|
329 | extern int XdmcpOptions(int argc, char **argv, int i);
|
---|
330 | extern void XdmcpSetAuthentication (ARRAY8Ptr name);
|
---|
331 | extern void XdmcpRegisterConnection (
|
---|
332 | int type,
|
---|
333 | char *address,
|
---|
334 | int addrlen);
|
---|
335 | extern void XdmcpRegisterAuthorizations (void);
|
---|
336 | extern void XdmcpRegisterAuthorization (char *name, int namelen);
|
---|
337 | extern void XdmcpRegisterDisplayClass (char *name, int length);
|
---|
338 | extern void XdmcpInit (void);
|
---|
339 | extern void XdmcpReset (void);
|
---|
340 | extern void XdmcpOpenDisplay(int sock);
|
---|
341 | extern void XdmcpCloseDisplay(int sock);
|
---|
342 | extern void XdmcpRegisterAuthentication (
|
---|
343 | char *name,
|
---|
344 | int namelen,
|
---|
345 | char *data,
|
---|
346 | int datalen,
|
---|
347 | ValidatorFunc Validator,
|
---|
348 | GeneratorFunc Generator,
|
---|
349 | AddAuthorFunc AddAuth);
|
---|
350 | extern int XdmcpCheckAuthentication (ARRAY8Ptr Name, ARRAY8Ptr Data, int packet_type);
|
---|
351 | extern int XdmcpAddAuthorization (ARRAY8Ptr name, ARRAY8Ptr data);
|
---|
352 |
|
---|
353 | struct sockaddr_in;
|
---|
354 | extern void XdmcpRegisterBroadcastAddress (struct sockaddr_in *addr);
|
---|
355 |
|
---|
356 | #ifdef HASXDMAUTH
|
---|
357 | extern void XdmAuthenticationInit (char *cookie, int cookie_length);
|
---|
358 | #endif
|
---|
359 |
|
---|
360 | #endif /* _OSDEP_H_ */
|
---|