osdep.h revision 678161bd
1/*********************************************************** 2 3Copyright 1987, 1998 The Open Group 4 5Permission to use, copy, modify, distribute, and sell this software and its 6documentation for any purpose is hereby granted without fee, provided that 7the above copyright notice appear in all copies and that both that 8copyright notice and this permission notice appear in supporting 9documentation. 10 11The above copyright notice and this permission notice shall be included in 12all copies or substantial portions of the Software. 13 14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 18AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 21Except as contained in this notice, the name of The Open Group shall not be 22used in advertising or otherwise to promote the sale, use or other dealings 23in this Software without prior written authorization from The Open Group. 24 25Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. 26 27 All Rights Reserved 28 29Permission to use, copy, modify, and distribute this software and its 30documentation for any purpose and without fee is hereby granted, 31provided that the above copyright notice appear in all copies and that 32both that copyright notice and this permission notice appear in 33supporting documentation, and that the name of Digital not be 34used in advertising or publicity pertaining to distribution of the 35software without specific, written prior permission. 36 37DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 38ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 39DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 40ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 41WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 42ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 43SOFTWARE. 44 45******************************************************************/ 46 47#ifdef HAVE_DIX_CONFIG_H 48#include <dix-config.h> 49#endif 50 51#ifndef _OSDEP_H_ 52#define _OSDEP_H_ 1 53 54#if defined(XDMCP) || defined(HASXDMAUTH) 55#include <X11/Xdmcp.h> 56#endif 57 58#ifdef _POSIX_SOURCE 59#include <limits.h> 60#else 61#define _POSIX_SOURCE 62#include <limits.h> 63#undef _POSIX_SOURCE 64#endif 65 66#ifndef OPEN_MAX 67#ifdef SVR4 68#define OPEN_MAX 512 69#else 70#include <sys/param.h> 71#ifndef OPEN_MAX 72#if defined(NOFILE) && !defined(NOFILES_MAX) 73#define OPEN_MAX NOFILE 74#else 75#if !defined(WIN32) || defined(__CYGWIN__) 76#define OPEN_MAX NOFILES_MAX 77#else 78#define OPEN_MAX 512 79#endif 80#endif 81#endif 82#endif 83#endif 84 85#include <X11/Xpoll.h> 86 87/* 88 * MAXSOCKS is used only for initialising MaxClients when no other method 89 * like sysconf(_SC_OPEN_MAX) is not supported. 90 */ 91 92#if OPEN_MAX <= 512 93#define MAXSOCKS (OPEN_MAX - 1) 94#else 95#define MAXSOCKS 512 96#endif 97 98/* MAXSELECT is the number of fds that select() can handle */ 99#define MAXSELECT (sizeof(fd_set) * NBBY) 100 101#include <stddef.h> 102 103#if defined(XDMCP) || defined(HASXDMAUTH) 104typedef Bool (*ValidatorFunc) (ARRAY8Ptr Auth, ARRAY8Ptr Data, int packet_type); 105typedef Bool (*GeneratorFunc) (ARRAY8Ptr Auth, ARRAY8Ptr Data, int packet_type); 106typedef Bool (*AddAuthorFunc) (unsigned name_length, const char *name, 107 unsigned data_length, char *data); 108#endif 109 110typedef struct _connectionInput *ConnectionInputPtr; 111typedef struct _connectionOutput *ConnectionOutputPtr; 112 113struct _osComm; 114 115#define AuthInitArgs void 116typedef void (*AuthInitFunc) (AuthInitArgs); 117 118#define AuthAddCArgs unsigned short data_length, const char *data, XID id 119typedef int (*AuthAddCFunc) (AuthAddCArgs); 120 121#define AuthCheckArgs unsigned short data_length, const char *data, ClientPtr client, const char **reason 122typedef XID (*AuthCheckFunc) (AuthCheckArgs); 123 124#define AuthFromIDArgs XID id, unsigned short *data_lenp, char **datap 125typedef int (*AuthFromIDFunc) (AuthFromIDArgs); 126 127#define AuthGenCArgs unsigned data_length, const char *data, XID id, unsigned *data_length_return, char **data_return 128typedef XID (*AuthGenCFunc) (AuthGenCArgs); 129 130#define AuthRemCArgs unsigned short data_length, const char *data 131typedef int (*AuthRemCFunc) (AuthRemCArgs); 132 133#define AuthRstCArgs void 134typedef int (*AuthRstCFunc) (AuthRstCArgs); 135 136typedef void (*OsCloseFunc) (ClientPtr); 137 138typedef int (*OsFlushFunc) (ClientPtr who, struct _osComm * oc, char *extraBuf, 139 int extraCount); 140 141typedef struct _osComm { 142 int fd; 143 ConnectionInputPtr input; 144 ConnectionOutputPtr output; 145 XID auth_id; /* authorization id */ 146 CARD32 conn_time; /* timestamp if not established, else 0 */ 147 struct _XtransConnInfo *trans_conn; /* transport connection object */ 148} OsCommRec, *OsCommPtr; 149 150extern int FlushClient(ClientPtr /*who */ , 151 OsCommPtr /*oc */ , 152 const void * /*extraBuf */ , 153 int /*extraCount */ 154 ); 155 156extern void FreeOsBuffers(OsCommPtr /*oc */ 157 ); 158 159#include "dix.h" 160 161extern fd_set AllSockets; 162extern fd_set AllClients; 163extern fd_set LastSelectMask; 164extern fd_set WellKnownConnections; 165extern fd_set EnabledDevices; 166extern fd_set ClientsWithInput; 167extern fd_set ClientsWriteBlocked; 168extern fd_set OutputPending; 169extern fd_set IgnoredClientsWithInput; 170 171#if !defined(WIN32) || defined(__CYGWIN__) 172extern int *ConnectionTranslation; 173#else 174extern int GetConnectionTranslation(int conn); 175extern void SetConnectionTranslation(int conn, int client); 176extern void ClearConnectionTranslation(void); 177#endif 178 179extern Bool NewOutputPending; 180extern Bool AnyClientsWriteBlocked; 181 182extern WorkQueuePtr workQueue; 183 184/* in WaitFor.c */ 185#if defined(WIN32) && !defined(__CYGWIN__) 186typedef long int fd_mask; 187#endif 188#define ffs mffs 189extern int mffs(fd_mask); 190 191/* in access.c */ 192extern Bool ComputeLocalClient(ClientPtr client); 193 194/* in auth.c */ 195extern void GenerateRandomData(int len, char *buf); 196 197/* in mitauth.c */ 198extern XID MitCheckCookie(AuthCheckArgs); 199extern XID MitGenerateCookie(AuthGenCArgs); 200extern int MitAddCookie(AuthAddCArgs); 201extern int MitFromID(AuthFromIDArgs); 202extern int MitRemoveCookie(AuthRemCArgs); 203extern int MitResetCookie(AuthRstCArgs); 204 205/* in xdmauth.c */ 206#ifdef HASXDMAUTH 207extern XID XdmCheckCookie(AuthCheckArgs); 208extern int XdmAddCookie(AuthAddCArgs); 209extern int XdmFromID(AuthFromIDArgs); 210extern int XdmRemoveCookie(AuthRemCArgs); 211extern int XdmResetCookie(AuthRstCArgs); 212#endif 213 214/* in rpcauth.c */ 215#ifdef SECURE_RPC 216extern void SecureRPCInit(AuthInitArgs); 217extern XID SecureRPCCheck(AuthCheckArgs); 218extern int SecureRPCAdd(AuthAddCArgs); 219extern int SecureRPCFromID(AuthFromIDArgs); 220extern int SecureRPCRemove(AuthRemCArgs); 221extern int SecureRPCReset(AuthRstCArgs); 222#endif 223 224#ifdef XDMCP 225/* in xdmcp.c */ 226extern void XdmcpUseMsg(void); 227extern int XdmcpOptions(int argc, char **argv, int i); 228extern void XdmcpRegisterConnection(int type, const char *address, int addrlen); 229extern void XdmcpRegisterAuthorizations(void); 230extern void XdmcpRegisterAuthorization(const char *name, int namelen); 231extern void XdmcpInit(void); 232extern void XdmcpReset(void); 233extern void XdmcpOpenDisplay(int sock); 234extern void XdmcpCloseDisplay(int sock); 235extern void XdmcpRegisterAuthentication(const char *name, 236 int namelen, 237 const char *data, 238 int datalen, 239 ValidatorFunc Validator, 240 GeneratorFunc Generator, 241 AddAuthorFunc AddAuth); 242 243struct sockaddr_in; 244extern void XdmcpRegisterBroadcastAddress(const struct sockaddr_in *addr); 245#endif 246 247#ifdef HASXDMAUTH 248extern void XdmAuthenticationInit(const char *cookie, int cookie_length); 249#endif 250 251#endif /* _OSDEP_H_ */ 252