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 | #if !defined(hpux) && !defined(SVR4) && !defined(SYSV)
|
---|
123 | #define HAS_GETDTABLESIZE
|
---|
124 | #endif
|
---|
125 |
|
---|
126 | #include <stddef.h>
|
---|
127 |
|
---|
128 | typedef Bool (*ValidatorFunc)(ARRAY8Ptr Auth, ARRAY8Ptr Data, int packet_type);
|
---|
129 | typedef Bool (*GeneratorFunc)(ARRAY8Ptr Auth, ARRAY8Ptr Data, int packet_type);
|
---|
130 | typedef Bool (*AddAuthorFunc)(unsigned name_length, char *name, unsigned data_length, char *data);
|
---|
131 |
|
---|
132 | typedef struct _connectionInput {
|
---|
133 | struct _connectionInput *next;
|
---|
134 | char *buffer; /* contains current client input */
|
---|
135 | char *bufptr; /* pointer to current start of data */
|
---|
136 | int bufcnt; /* count of bytes in buffer */
|
---|
137 | int lenLastReq;
|
---|
138 | int size;
|
---|
139 | } ConnectionInput, *ConnectionInputPtr;
|
---|
140 |
|
---|
141 | typedef struct _connectionOutput {
|
---|
142 | struct _connectionOutput *next;
|
---|
143 | int size;
|
---|
144 | unsigned char *buf;
|
---|
145 | int count;
|
---|
146 | #ifdef LBX
|
---|
147 | Bool nocompress;
|
---|
148 | #endif
|
---|
149 | } ConnectionOutput, *ConnectionOutputPtr;
|
---|
150 |
|
---|
151 | #ifdef K5AUTH
|
---|
152 | typedef struct _k5_state {
|
---|
153 | int stageno; /* current stage of auth protocol */
|
---|
154 | pointer srvcreds; /* server credentials */
|
---|
155 | pointer srvname; /* server principal name */
|
---|
156 | pointer ktname; /* key table: principal-key pairs */
|
---|
157 | pointer skey; /* session key */
|
---|
158 | } k5_state;
|
---|
159 | #endif
|
---|
160 |
|
---|
161 | #ifdef LBX
|
---|
162 | typedef struct _LbxProxy *OsProxyPtr;
|
---|
163 | #endif
|
---|
164 |
|
---|
165 | struct _osComm;
|
---|
166 |
|
---|
167 | #define AuthInitArgs void
|
---|
168 | typedef void (*AuthInitFunc) (AuthInitArgs);
|
---|
169 |
|
---|
170 | #define AuthAddCArgs unsigned short data_length, char *data, XID id
|
---|
171 | typedef int (*AuthAddCFunc) (AuthAddCArgs);
|
---|
172 |
|
---|
173 | #define AuthCheckArgs unsigned short data_length, char *data, ClientPtr client, char **reason
|
---|
174 | typedef XID (*AuthCheckFunc) (AuthCheckArgs);
|
---|
175 |
|
---|
176 | #define AuthFromIDArgs XID id, unsigned short *data_lenp, char **datap
|
---|
177 | typedef int (*AuthFromIDFunc) (AuthFromIDArgs);
|
---|
178 |
|
---|
179 | #define AuthGenCArgs unsigned data_length, char *data, XID id, unsigned *data_length_return, char **data_return
|
---|
180 | typedef XID (*AuthGenCFunc) (AuthGenCArgs);
|
---|
181 |
|
---|
182 | #define AuthRemCArgs unsigned short data_length, char *data
|
---|
183 | typedef int (*AuthRemCFunc) (AuthRemCArgs);
|
---|
184 |
|
---|
185 | #define AuthRstCArgs void
|
---|
186 | typedef int (*AuthRstCFunc) (AuthRstCArgs);
|
---|
187 |
|
---|
188 | #define AuthToIDArgs unsigned short data_length, char *data
|
---|
189 | typedef XID (*AuthToIDFunc) (AuthToIDArgs);
|
---|
190 |
|
---|
191 | typedef void (*OsCloseFunc)(ClientPtr);
|
---|
192 |
|
---|
193 | typedef int (*OsFlushFunc)(ClientPtr who, struct _osComm * oc, char* extraBuf, int extraCount);
|
---|
194 |
|
---|
195 | typedef struct _osComm {
|
---|
196 | int fd;
|
---|
197 | ConnectionInputPtr input;
|
---|
198 | ConnectionOutputPtr output;
|
---|
199 | XID auth_id; /* authorization id */
|
---|
200 | #ifdef K5AUTH
|
---|
201 | k5_state authstate; /* state of setup auth conversation */
|
---|
202 | #endif
|
---|
203 | CARD32 conn_time; /* timestamp if not established, else 0 */
|
---|
204 | struct _XtransConnInfo *trans_conn; /* transport connection object */
|
---|
205 | #ifdef LBX
|
---|
206 | OsProxyPtr proxy;
|
---|
207 | ConnectionInputPtr largereq;
|
---|
208 | OsCloseFunc Close;
|
---|
209 | OsFlushFunc Flush;
|
---|
210 | #endif
|
---|
211 | } OsCommRec, *OsCommPtr;
|
---|
212 |
|
---|
213 | #ifdef LBX
|
---|
214 | #define FlushClient(who, oc, extraBuf, extraCount) \
|
---|
215 | (*(oc)->Flush)(who, oc, extraBuf, extraCount)
|
---|
216 | extern int StandardFlushClient(
|
---|
217 | ClientPtr /*who*/,
|
---|
218 | OsCommPtr /*oc*/,
|
---|
219 | char* /*extraBuf*/,
|
---|
220 | int /*extraCount*/
|
---|
221 | );
|
---|
222 | extern int LbxFlushClient(ClientPtr /*who*/, OsCommPtr /*oc*/,
|
---|
223 | char * /*extraBuf*/, int /*extraCount*/);
|
---|
224 | #else
|
---|
225 | extern int FlushClient(
|
---|
226 | ClientPtr /*who*/,
|
---|
227 | OsCommPtr /*oc*/,
|
---|
228 | char* /*extraBuf*/,
|
---|
229 | int /*extraCount*/
|
---|
230 | );
|
---|
231 | #endif
|
---|
232 |
|
---|
233 | extern void FreeOsBuffers(
|
---|
234 | OsCommPtr /*oc*/
|
---|
235 | );
|
---|
236 |
|
---|
237 | #include "dix.h"
|
---|
238 |
|
---|
239 | extern ConnectionInputPtr AllocateInputBuffer(void);
|
---|
240 |
|
---|
241 | extern ConnectionOutputPtr AllocateOutputBuffer(void);
|
---|
242 |
|
---|
243 | extern fd_set AllSockets;
|
---|
244 | extern fd_set AllClients;
|
---|
245 | extern fd_set LastSelectMask;
|
---|
246 | extern fd_set WellKnownConnections;
|
---|
247 | extern fd_set EnabledDevices;
|
---|
248 | extern fd_set ClientsWithInput;
|
---|
249 | extern fd_set ClientsWriteBlocked;
|
---|
250 | extern fd_set OutputPending;
|
---|
251 | extern fd_set IgnoredClientsWithInput;
|
---|
252 |
|
---|
253 | #ifndef WIN32
|
---|
254 | extern int *ConnectionTranslation;
|
---|
255 | #else
|
---|
256 | extern int GetConnectionTranslation(int conn);
|
---|
257 | extern void SetConnectionTranslation(int conn, int client);
|
---|
258 | extern void ClearConnectionTranslation();
|
---|
259 | #endif
|
---|
260 |
|
---|
261 | extern Bool NewOutputPending;
|
---|
262 | extern Bool AnyClientsWriteBlocked;
|
---|
263 | extern Bool CriticalOutputPending;
|
---|
264 |
|
---|
265 | extern int timesThisConnection;
|
---|
266 | extern ConnectionInputPtr FreeInputs;
|
---|
267 | extern ConnectionOutputPtr FreeOutputs;
|
---|
268 | extern OsCommPtr AvailableInput;
|
---|
269 |
|
---|
270 | extern WorkQueuePtr workQueue;
|
---|
271 |
|
---|
272 | /* added by raphael */
|
---|
273 | #ifdef WIN32
|
---|
274 | typedef long int fd_mask;
|
---|
275 | #endif
|
---|
276 | #define ffs mffs
|
---|
277 | extern int mffs(fd_mask);
|
---|
278 |
|
---|
279 | /* in auth.c */
|
---|
280 | extern void GenerateRandomData (int len, char *buf);
|
---|
281 |
|
---|
282 | /* in mitauth.c */
|
---|
283 | extern XID MitCheckCookie (AuthCheckArgs);
|
---|
284 | extern XID MitGenerateCookie (AuthGenCArgs);
|
---|
285 | extern XID MitToID (AuthToIDArgs);
|
---|
286 | extern int MitAddCookie (AuthAddCArgs);
|
---|
287 | extern int MitFromID (AuthFromIDArgs);
|
---|
288 | extern int MitRemoveCookie (AuthRemCArgs);
|
---|
289 | extern int MitResetCookie (AuthRstCArgs);
|
---|
290 |
|
---|
291 | /* in xdmauth.c */
|
---|
292 | #ifdef HASXDMAUTH
|
---|
293 | extern XID XdmCheckCookie (AuthCheckArgs);
|
---|
294 | extern XID XdmToID (AuthToIDArgs);
|
---|
295 | extern int XdmAddCookie (AuthAddCArgs);
|
---|
296 | extern int XdmFromID (AuthFromIDArgs);
|
---|
297 | extern int XdmRemoveCookie (AuthRemCArgs);
|
---|
298 | extern int XdmResetCookie (AuthRstCArgs);
|
---|
299 | #endif
|
---|
300 |
|
---|
301 | /* in rpcauth.c */
|
---|
302 | #ifdef SECURE_RPC
|
---|
303 | extern void SecureRPCInit (AuthInitArgs);
|
---|
304 | extern XID SecureRPCCheck (AuthCheckArgs);
|
---|
305 | extern XID SecureRPCToID (AuthToIDArgs);
|
---|
306 | extern int SecureRPCAdd (AuthAddCArgs);
|
---|
307 | extern int SecureRPCFromID (AuthFromIDArgs);
|
---|
308 | extern int SecureRPCRemove (AuthRemCArgs);
|
---|
309 | extern int SecureRPCReset (AuthRstCArgs);
|
---|
310 | #endif
|
---|
311 |
|
---|
312 | /* in k5auth.c */
|
---|
313 | #ifdef K5AUTH
|
---|
314 | extern XID K5Check (AuthCheckArgs);
|
---|
315 | extern XID K5ToID (AuthToIDArgs);
|
---|
316 | extern int K5Add (AuthAddCArgs);
|
---|
317 | extern int K5FromID (AuthFromIDArgs);
|
---|
318 | extern int K5Remove (AuthRemCArgs);
|
---|
319 | extern int K5Reset (AuthRstCArgs);
|
---|
320 | #endif
|
---|
321 |
|
---|
322 | /* in secauth.c */
|
---|
323 | extern XID AuthSecurityCheck (AuthCheckArgs);
|
---|
324 |
|
---|
325 | /* in xdmcp.c */
|
---|
326 | extern void XdmcpUseMsg (void);
|
---|
327 | extern int XdmcpOptions(int argc, char **argv, int i);
|
---|
328 | extern void XdmcpSetAuthentication (ARRAY8Ptr name);
|
---|
329 | extern void XdmcpRegisterConnection (
|
---|
330 | int type,
|
---|
331 | char *address,
|
---|
332 | int addrlen);
|
---|
333 | extern void XdmcpRegisterAuthorizations (void);
|
---|
334 | extern void XdmcpRegisterAuthorization (char *name, int namelen);
|
---|
335 | extern void XdmcpRegisterDisplayClass (char *name, int length);
|
---|
336 | extern void XdmcpInit (void);
|
---|
337 | extern void XdmcpReset (void);
|
---|
338 | extern void XdmcpOpenDisplay(int sock);
|
---|
339 | extern void XdmcpCloseDisplay(int sock);
|
---|
340 | extern void XdmcpRegisterAuthentication (
|
---|
341 | char *name,
|
---|
342 | int namelen,
|
---|
343 | char *data,
|
---|
344 | int datalen,
|
---|
345 | ValidatorFunc Validator,
|
---|
346 | GeneratorFunc Generator,
|
---|
347 | AddAuthorFunc AddAuth);
|
---|
348 | extern int XdmcpCheckAuthentication (ARRAY8Ptr Name, ARRAY8Ptr Data, int packet_type);
|
---|
349 | extern int XdmcpAddAuthorization (ARRAY8Ptr name, ARRAY8Ptr data);
|
---|
350 |
|
---|
351 | struct sockaddr_in;
|
---|
352 | extern void XdmcpRegisterBroadcastAddress (struct sockaddr_in *addr);
|
---|
353 |
|
---|
354 | #ifdef HASXDMAUTH
|
---|
355 | extern void XdmAuthenticationInit (char *cookie, int cookie_length);
|
---|
356 | #endif
|
---|
357 |
|
---|
358 | #endif /* _OSDEP_H_ */
|
---|