1/* 2Copyright 1987, 1998 The Open Group 3 4Permission to use, copy, modify, distribute, and sell this software and its 5documentation for any purpose is hereby granted without fee, provided that 6the above copyright notice appear in all copies and that both that 7copyright notice and this permission notice appear in supporting 8documentation. 9 10The above copyright notice and this permission notice shall be included in 11all copies or substantial portions of the Software. 12 13THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 17AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 20Except as contained in this notice, the name of The Open Group shall not be 21used in advertising or otherwise to promote the sale, use or other dealings 22in this Software without prior written authorization from The Open Group. 23 * Copyright 1990, 1991 Network Computing Devices; 24 * Portions Copyright 1987 by Digital Equipment Corporation 25 * 26 * Permission to use, copy, modify, distribute, and sell this software and its 27 * documentation for any purpose is hereby granted without fee, provided that 28 * the above copyright notice appear in all copies and that both that 29 * copyright notice and this permission notice appear in supporting 30 * documentation, and that the names of Network Computing Devices, 31 * or Digital not be used in advertising or 32 * publicity pertaining to distribution of the software without specific, 33 * written prior permission. Network Computing Devices, or Digital 34 * make no representations about the 35 * suitability of this software for any purpose. It is provided "as is" 36 * without express or implied warranty. 37 * 38 * NETWORK COMPUTING DEVICES, AND DIGITAL DISCLAIM ALL WARRANTIES WITH 39 * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 40 * AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES, OR DIGITAL BE 41 * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 42 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 43 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 44 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 45 * 46 */ 47 48#ifndef _OS_H_ 49#define _OS_H_ 50 51typedef struct _FontPathRec *FontPathPtr; 52typedef struct _alt_server *AlternateServerPtr; 53typedef struct _auth *AuthPtr; 54 55#include <X11/fonts/FSproto.h> 56#include <X11/Xfuncproto.h> 57#include "client.h" 58#include "misc.h" 59 60#if __has_attribute(alloc_size) 61#define XFS_ATTRIBUTE_ALLOC_SIZE(ARGS) __attribute__ ((alloc_size ARGS)) 62#else 63#define XFS_ATTRIBUTE_ALLOC_SIZE(ARGS) 64#endif 65 66#if __has_attribute(malloc) 67# if defined(__clang__) || (defined(__GNUC__) && __GNUC__ < 11) 68/* Clang or older gcc do not support the optional deallocator argument */ 69# define XFS_ATTRIBUTE_MALLOC(ARGS) __attribute__((malloc)) 70# else 71# define XFS_ATTRIBUTE_MALLOC(ARGS) __attribute__((malloc ARGS)) 72# endif 73#else 74# define XFS_ATTRIBUTE_MALLOC(ARGS) 75#endif 76 77#define XFS_ALLOCATOR(DEALLOC, SIZE) \ 78 XFS_ATTRIBUTE_MALLOC(DEALLOC) XFS_ATTRIBUTE_ALLOC_SIZE(SIZE) 79 80typedef pointer FID; 81 82#define ALLOCATE_LOCAL_FALLBACK(_size) FSalloc((unsigned long)_size) 83#define DEALLOCATE_LOCAL_FALLBACK(_ptr) FSfree((pointer)_ptr) 84 85#include "X11/Xalloca.h" 86 87#define MAX_REQUEST_SIZE 8192 88 89extern int ListenPort; 90extern Bool UseSyslog; 91extern Bool CloneSelf; 92extern char ErrorFile[]; 93 94struct _osComm; /* FIXME: osCommPtr */ 95 96/* os/config.c */ 97extern int ReadConfigFile(const char *filename); 98 99/* os/connection.c */ 100extern void AttendClient(ClientPtr client); 101extern void CheckConnections(void); 102extern void CloseDownConnection(ClientPtr client); 103extern void IgnoreClient(ClientPtr client); 104extern void MakeNewConnections(void); 105extern void ReapAnyOldClients(void); 106extern void ResetSockets(void); 107extern void CloseSockets(void); 108extern void StopListening(void); 109 110/* os/daemon.c */ 111extern void BecomeDaemon(void); 112extern void DetachStdio(void); 113 114/* os/error.c */ 115extern void Error(const char *str); 116extern void InitErrors(void); 117extern void CloseErrors(void); 118extern void NoticeF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1, 2); 119extern void ErrorF(const char * f, ...) _X_ATTRIBUTE_PRINTF(1, 2); 120extern void FatalError(const char* f, ...) _X_ATTRIBUTE_PRINTF(1, 2) 121 _X_NORETURN; 122 123/* os/io.c */ 124extern Bool InsertFakeRequest(ClientPtr client, char *data, int count); 125extern int FlushClient(ClientPtr client, struct _osComm *oc, char *extraBuf, int extraCount, int padsize); 126extern int ReadRequest(ClientPtr client); 127extern void FlushAllOutput(void); 128extern void FreeOsBuffers(struct _osComm *oc); 129extern void ResetCurrentRequest(ClientPtr client); 130extern void ResetOsBuffers(void); 131extern void WriteToClient(ClientPtr client, int count, char *buf); 132extern void WriteToClientUnpadded(ClientPtr client, int count, char *buf); 133 134/* os/osglue.c */ 135extern int ListCatalogues(const char *pattern, int patlen, int maxnames, char **catalogues, int *len); 136extern int ValidateCatalogues(int *num, char *cats); 137extern int SetAlternateServers(char *list); 138extern int ListAlternateServers(AlternateServerPtr *svrs); 139extern int CloneMyself(void); 140 141/* os/osinit.c */ 142extern void OsInit(void); 143 144/* os/utils.c */ 145extern void AutoResetServer (int n); 146extern void CleanupChild (int n); 147extern void GiveUp (int n); 148extern void ServerCacheFlush (int n); 149extern void ServerReconfig (int n); 150extern unsigned int GetTimeInMillis (void); 151extern void FSfree(pointer); 152extern pointer FSalloc(unsigned long) 153 XFS_ATTRIBUTE_ALLOC_SIZE((1)) XFS_ATTRIBUTE_MALLOC((FSfree)); 154extern pointer FSallocarray(unsigned long, unsigned long) 155 XFS_ATTRIBUTE_ALLOC_SIZE((1,2)) XFS_ATTRIBUTE_MALLOC((FSfree)); 156extern pointer FScalloc (unsigned long, unsigned long) 157 XFS_ATTRIBUTE_ALLOC_SIZE((1,2)) XFS_ATTRIBUTE_MALLOC((FSfree)); 158extern pointer FSrealloc(pointer, unsigned long) 159 XFS_ATTRIBUTE_ALLOC_SIZE((2)); 160extern pointer FSreallocarray (pointer, unsigned long, unsigned long) 161 XFS_ATTRIBUTE_ALLOC_SIZE((2,3)); 162extern void ProcessCmdLine (int argc, char **argv); 163extern void ProcessLSoption (char *str); 164extern void SetUserId(void); 165extern void SetDaemonState(void); 166 167/* os/waitfor.c */ 168extern int WaitForSomething(int *pClientsReady); 169 170extern void SetConfigValues(void); 171 172 173#endif /* _OS_H_ */ 174