1 /* 2 Copyright 1987, 1998 The Open Group 3 4 Permission to use, copy, modify, distribute, and sell this software and its 5 documentation for any purpose is hereby granted without fee, provided that 6 the above copyright notice appear in all copies and that both that 7 copyright notice and this permission notice appear in supporting 8 documentation. 9 10 The above copyright notice and this permission notice shall be included in 11 all copies or substantial portions of the Software. 12 13 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 17 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 20 Except as contained in this notice, the name of The Open Group shall not be 21 used in advertising or otherwise to promote the sale, use or other dealings 22 in 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 51 typedef struct _FontPathRec *FontPathPtr; 52 typedef struct _alt_server *AlternateServerPtr; 53 typedef 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 80 typedef 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 89 extern int ListenPort; 90 extern Bool UseSyslog; 91 extern Bool CloneSelf; 92 extern char ErrorFile[]; 93 94 struct _osComm; /* FIXME: osCommPtr */ 95 96 /* os/config.c */ 97 extern int ReadConfigFile(const char *filename); 98 99 /* os/connection.c */ 100 extern void AttendClient(ClientPtr client); 101 extern void CheckConnections(void); 102 extern void CloseDownConnection(ClientPtr client); 103 extern void IgnoreClient(ClientPtr client); 104 extern void MakeNewConnections(void); 105 extern void ReapAnyOldClients(void); 106 extern void ResetSockets(void); 107 extern void CloseSockets(void); 108 extern void StopListening(void); 109 110 /* os/daemon.c */ 111 extern void BecomeDaemon(void); 112 extern void DetachStdio(void); 113 114 /* os/error.c */ 115 extern void Error(const char *str); 116 extern void InitErrors(void); 117 extern void CloseErrors(void); 118 extern void NoticeF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1, 2); 119 extern void ErrorF(const char * f, ...) _X_ATTRIBUTE_PRINTF(1, 2); 120 extern void FatalError(const char* f, ...) _X_ATTRIBUTE_PRINTF(1, 2) 121 _X_NORETURN; 122 123 /* os/io.c */ 124 extern Bool InsertFakeRequest(ClientPtr client, char *data, int count); 125 extern int FlushClient(ClientPtr client, struct _osComm *oc, char *extraBuf, int extraCount, int padsize); 126 extern int ReadRequest(ClientPtr client); 127 extern void FlushAllOutput(void); 128 extern void FreeOsBuffers(struct _osComm *oc); 129 extern void ResetCurrentRequest(ClientPtr client); 130 extern void ResetOsBuffers(void); 131 extern void WriteToClient(ClientPtr client, int count, char *buf); 132 extern void WriteToClientUnpadded(ClientPtr client, int count, char *buf); 133 134 /* os/osglue.c */ 135 extern int ListCatalogues(const char *pattern, int patlen, int maxnames, char **catalogues, int *len); 136 extern int ValidateCatalogues(int *num, char *cats); 137 extern int SetAlternateServers(char *list); 138 extern int ListAlternateServers(AlternateServerPtr *svrs); 139 extern int CloneMyself(void); 140 141 /* os/osinit.c */ 142 extern void OsInit(void); 143 144 /* os/utils.c */ 145 extern void AutoResetServer (int n); 146 extern void CleanupChild (int n); 147 extern void GiveUp (int n); 148 extern void ServerCacheFlush (int n); 149 extern void ServerReconfig (int n); 150 extern unsigned int GetTimeInMillis (void); 151 extern void FSfree(pointer); 152 extern pointer FSalloc(unsigned long) 153 XFS_ATTRIBUTE_ALLOC_SIZE((1)) XFS_ATTRIBUTE_MALLOC((FSfree)); 154 extern pointer FSallocarray(unsigned long, unsigned long) 155 XFS_ATTRIBUTE_ALLOC_SIZE((1,2)) XFS_ATTRIBUTE_MALLOC((FSfree)); 156 extern pointer FScalloc (unsigned long, unsigned long) 157 XFS_ATTRIBUTE_ALLOC_SIZE((1,2)) XFS_ATTRIBUTE_MALLOC((FSfree)); 158 extern pointer FSrealloc(pointer, unsigned long) 159 XFS_ATTRIBUTE_ALLOC_SIZE((2)); 160 extern pointer FSreallocarray (pointer, unsigned long, unsigned long) 161 XFS_ATTRIBUTE_ALLOC_SIZE((2,3)); 162 extern void ProcessCmdLine (int argc, char **argv); 163 extern void ProcessLSoption (char *str); 164 extern void SetUserId(void); 165 extern void SetDaemonState(void); 166 167 /* os/waitfor.c */ 168 extern int WaitForSomething(int *pClientsReady); 169 170 extern void SetConfigValues(void); 171 172 173 #endif /* _OS_H_ */ 174