First import
[xorg_rtime.git] / xorg-server-1.4 / os / osdep.h
blob2d455aa6766d0e22275d4b0f0675913e54e1c3bd
1 /***********************************************************
3 Copyright 1987, 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
9 documentation.
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 Except as contained in this notice, the name of The Open Group shall not be
22 used in advertising or otherwise to promote the sale, use or other dealings
23 in this Software without prior written authorization from The Open Group.
26 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
28 All Rights Reserved
30 Permission to use, copy, modify, and distribute this software and its
31 documentation for any purpose and without fee is hereby granted,
32 provided that the above copyright notice appear in all copies and that
33 both that copyright notice and this permission notice appear in
34 supporting documentation, and that the name of Digital not be
35 used in advertising or publicity pertaining to distribution of the
36 software without specific, written prior permission.
38 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
39 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
40 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
41 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
42 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
43 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
44 SOFTWARE.
46 ******************************************************************/
48 #ifdef HAVE_DIX_CONFIG_H
49 #include <dix-config.h>
50 #endif
52 #ifndef _OSDEP_H_
53 #define _OSDEP_H_ 1
55 #define BOTIMEOUT 200 /* in milliseconds */
56 #define BUFSIZE 4096
57 #define BUFWATERMARK 8192
59 #include <X11/Xdmcp.h>
61 #ifndef sgi /* SGI defines OPEN_MAX in a useless way */
62 #ifndef X_NOT_POSIX
63 #ifdef _POSIX_SOURCE
64 #include <limits.h>
65 #else
66 #define _POSIX_SOURCE
67 #include <limits.h>
68 #undef _POSIX_SOURCE
69 #endif
70 #else /* X_NOT_POSIX */
71 #ifdef WIN32
72 #define _POSIX_
73 #include <limits.h>
74 #undef _POSIX_
75 #endif
76 #endif /* X_NOT_POSIX */
77 #endif
79 #ifdef __QNX__
80 #define NOFILES_MAX 256
81 #endif
82 #ifndef OPEN_MAX
83 #ifdef SVR4
84 #define OPEN_MAX 256
85 #else
86 #include <sys/param.h>
87 #ifndef OPEN_MAX
88 #if defined(NOFILE) && !defined(NOFILES_MAX)
89 #define OPEN_MAX NOFILE
90 #else
91 #if !defined(WIN32)
92 #define OPEN_MAX NOFILES_MAX
93 #else
94 #define OPEN_MAX 256
95 #endif
96 #endif
97 #endif
98 #endif
99 #endif
101 #include <X11/Xpoll.h>
104 * MAXSOCKS is used only for initialising MaxClients when no other method
105 * like sysconf(_SC_OPEN_MAX) is not supported.
108 #if OPEN_MAX <= 256
109 #define MAXSOCKS (OPEN_MAX - 1)
110 #else
111 #define MAXSOCKS 256
112 #endif
114 /* MAXSELECT is the number of fds that select() can handle */
115 #define MAXSELECT (sizeof(fd_set) * NBBY)
117 #ifndef HAS_GETDTABLESIZE
118 #if !defined(hpux) && !defined(SVR4) && !defined(SYSV)
119 #define HAS_GETDTABLESIZE
120 #endif
121 #endif
123 #include <stddef.h>
125 typedef Bool (*ValidatorFunc)(ARRAY8Ptr Auth, ARRAY8Ptr Data, int packet_type);
126 typedef Bool (*GeneratorFunc)(ARRAY8Ptr Auth, ARRAY8Ptr Data, int packet_type);
127 typedef Bool (*AddAuthorFunc)(unsigned name_length, char *name, unsigned data_length, char *data);
129 typedef struct _connectionInput {
130 struct _connectionInput *next;
131 char *buffer; /* contains current client input */
132 char *bufptr; /* pointer to current start of data */
133 int bufcnt; /* count of bytes in buffer */
134 int lenLastReq;
135 int size;
136 } ConnectionInput, *ConnectionInputPtr;
138 typedef struct _connectionOutput {
139 struct _connectionOutput *next;
140 int size;
141 unsigned char *buf;
142 int count;
143 } ConnectionOutput, *ConnectionOutputPtr;
145 struct _osComm;
147 #define AuthInitArgs void
148 typedef void (*AuthInitFunc) (AuthInitArgs);
150 #define AuthAddCArgs unsigned short data_length, char *data, XID id
151 typedef int (*AuthAddCFunc) (AuthAddCArgs);
153 #define AuthCheckArgs unsigned short data_length, char *data, ClientPtr client, char **reason
154 typedef XID (*AuthCheckFunc) (AuthCheckArgs);
156 #define AuthFromIDArgs XID id, unsigned short *data_lenp, char **datap
157 typedef int (*AuthFromIDFunc) (AuthFromIDArgs);
159 #define AuthGenCArgs unsigned data_length, char *data, XID id, unsigned *data_length_return, char **data_return
160 typedef XID (*AuthGenCFunc) (AuthGenCArgs);
162 #define AuthRemCArgs unsigned short data_length, char *data
163 typedef int (*AuthRemCFunc) (AuthRemCArgs);
165 #define AuthRstCArgs void
166 typedef int (*AuthRstCFunc) (AuthRstCArgs);
168 #define AuthToIDArgs unsigned short data_length, char *data
169 typedef XID (*AuthToIDFunc) (AuthToIDArgs);
171 typedef void (*OsCloseFunc)(ClientPtr);
173 typedef int (*OsFlushFunc)(ClientPtr who, struct _osComm * oc, char* extraBuf, int extraCount);
175 typedef struct _osComm {
176 int fd;
177 ConnectionInputPtr input;
178 ConnectionOutputPtr output;
179 XID auth_id; /* authorization id */
180 CARD32 conn_time; /* timestamp if not established, else 0 */
181 struct _XtransConnInfo *trans_conn; /* transport connection object */
182 } OsCommRec, *OsCommPtr;
184 extern int FlushClient(
185 ClientPtr /*who*/,
186 OsCommPtr /*oc*/,
187 char* /*extraBuf*/,
188 int /*extraCount*/
191 extern void FreeOsBuffers(
192 OsCommPtr /*oc*/
195 #include "dix.h"
197 extern fd_set AllSockets;
198 extern fd_set AllClients;
199 extern fd_set LastSelectMask;
200 extern fd_set WellKnownConnections;
201 extern fd_set EnabledDevices;
202 extern fd_set ClientsWithInput;
203 extern fd_set ClientsWriteBlocked;
204 extern fd_set OutputPending;
205 extern fd_set IgnoredClientsWithInput;
207 #ifndef WIN32
208 extern int *ConnectionTranslation;
209 #else
210 extern int GetConnectionTranslation(int conn);
211 extern void SetConnectionTranslation(int conn, int client);
212 extern void ClearConnectionTranslation();
213 #endif
215 extern Bool NewOutputPending;
216 extern Bool AnyClientsWriteBlocked;
218 extern WorkQueuePtr workQueue;
220 /* added by raphael */
221 #ifdef WIN32
222 typedef long int fd_mask;
223 #endif
224 #define ffs mffs
225 extern int mffs(fd_mask);
227 /* in auth.c */
228 extern void GenerateRandomData (int len, char *buf);
230 /* in mitauth.c */
231 extern XID MitCheckCookie (AuthCheckArgs);
232 extern XID MitGenerateCookie (AuthGenCArgs);
233 extern XID MitToID (AuthToIDArgs);
234 extern int MitAddCookie (AuthAddCArgs);
235 extern int MitFromID (AuthFromIDArgs);
236 extern int MitRemoveCookie (AuthRemCArgs);
237 extern int MitResetCookie (AuthRstCArgs);
239 /* in xdmauth.c */
240 #ifdef HASXDMAUTH
241 extern XID XdmCheckCookie (AuthCheckArgs);
242 extern XID XdmToID (AuthToIDArgs);
243 extern int XdmAddCookie (AuthAddCArgs);
244 extern int XdmFromID (AuthFromIDArgs);
245 extern int XdmRemoveCookie (AuthRemCArgs);
246 extern int XdmResetCookie (AuthRstCArgs);
247 #endif
249 /* in rpcauth.c */
250 #ifdef SECURE_RPC
251 extern void SecureRPCInit (AuthInitArgs);
252 extern XID SecureRPCCheck (AuthCheckArgs);
253 extern XID SecureRPCToID (AuthToIDArgs);
254 extern int SecureRPCAdd (AuthAddCArgs);
255 extern int SecureRPCFromID (AuthFromIDArgs);
256 extern int SecureRPCRemove (AuthRemCArgs);
257 extern int SecureRPCReset (AuthRstCArgs);
258 #endif
260 /* in secauth.c */
261 extern XID AuthSecurityCheck (AuthCheckArgs);
263 /* in xdmcp.c */
264 extern void XdmcpUseMsg (void);
265 extern int XdmcpOptions(int argc, char **argv, int i);
266 extern void XdmcpRegisterConnection (
267 int type,
268 char *address,
269 int addrlen);
270 extern void XdmcpRegisterAuthorizations (void);
271 extern void XdmcpRegisterAuthorization (char *name, int namelen);
272 extern void XdmcpInit (void);
273 extern void XdmcpReset (void);
274 extern void XdmcpOpenDisplay(int sock);
275 extern void XdmcpCloseDisplay(int sock);
276 extern void XdmcpRegisterAuthentication (
277 char *name,
278 int namelen,
279 char *data,
280 int datalen,
281 ValidatorFunc Validator,
282 GeneratorFunc Generator,
283 AddAuthorFunc AddAuth);
285 struct sockaddr_in;
286 extern void XdmcpRegisterBroadcastAddress (struct sockaddr_in *addr);
288 #ifdef HASXDMAUTH
289 extern void XdmAuthenticationInit (char *cookie, int cookie_length);
290 #endif
292 #endif /* _OSDEP_H_ */