1 /***********************************************************
3 Copyright (c) 1987 X Consortium
5 Permission is hereby granted, free of charge, to any person obtaining a copy
6 of this software and associated documentation files (the "Software"), to deal
7 in the Software without restriction, including without limitation the rights
8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 copies of the Software, and to permit persons to whom the Software is
10 furnished to do so, subject to the following conditions:
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
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 X CONSORTIUM 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.
22 Except as contained in this notice, the name of the X Consortium 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 X Consortium.
27 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
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.
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
47 ******************************************************************/
49 /* $XConsortium: os.h /main/60 1996/12/15 21:25:13 rws $ */
50 /* $XFree86: xc/programs/Xserver/include/os.h,v 3.16.2.1 1998/01/22 10:47:13 dawes Exp $ */
55 #define ALLOCATE_LOCAL_FALLBACK(_size) Xalloc((unsigned long)(_size))
56 #define DEALLOCATE_LOCAL_FALLBACK(_ptr) Xfree((pointer)(_ptr))
59 #define NullFID ((FID) 0)
61 #define SCREEN_SAVER_ON 0
62 #define SCREEN_SAVER_OFF 1
63 #define SCREEN_SAVER_FORCER 2
64 #define SCREEN_SAVER_CYCLE 3
66 #ifndef MAX_REQUEST_SIZE
67 #define MAX_REQUEST_SIZE 65535
69 #ifndef MAX_BIG_REQUEST_SIZE
70 #define MAX_BIG_REQUEST_SIZE 1048575
74 typedef struct _FontPathRec *FontPathPtr;
75 typedef struct _NewClientRec *NewClientPtr;
77 #define xnfalloc(size) XNFalloc((unsigned long)(size))
78 #define xnfrealloc(ptr, size) XNFrealloc((pointer)(ptr), (unsigned long)(size))
80 #define xalloc(size) Xalloc((unsigned long)(size))
81 #define xnfalloc(size) XNFalloc((unsigned long)(size))
82 #define xcalloc(_num, _size) Xcalloc((unsigned long)(_num)*(unsigned long)(_size))
83 #define xrealloc(ptr, size) Xrealloc((pointer)(ptr), (unsigned long)(size))
84 #define xnfrealloc(ptr, size) XNFrealloc((pointer)(ptr), (unsigned long)(size))
85 #define xfree(ptr) Xfree((pointer)(ptr))
90 #ifndef X_NOT_STDC_ENV
100 /* have to put $(SIGNAL_DEFINES) in DEFINES in Imakefile to get this right */
101 #ifdef SIGNALRETURNSINT
107 extern Bool OsDelayInitColors;
109 extern int WaitForSomething(
110 #if NeedFunctionPrototypes
111 int* /*pClientsReady*/
116 #define ReadRequestFromClient(client) ((client)->readRequest(client))
117 extern int StandardReadRequestFromClient(
118 #if NeedFunctionPrototypes
123 extern int ReadRequestFromClient(
124 #if NeedFunctionPrototypes
130 extern Bool InsertFakeRequest(
131 #if NeedFunctionPrototypes
132 ClientPtr /*client*/,
138 extern int ResetCurrentRequest(
139 #if NeedFunctionPrototypes
144 extern void FlushAllOutput(
145 #if NeedFunctionPrototypes
150 extern void FlushIfCriticalOutputPending(
151 #if NeedFunctionPrototypes
156 extern void SetCriticalOutputPending(
157 #if NeedFunctionPrototypes
162 extern int WriteToClient(
163 #if NeedFunctionPrototypes
170 extern void ResetOsBuffers(
171 #if NeedFunctionPrototypes
176 extern void CreateWellKnownSockets(
177 #if NeedFunctionPrototypes
182 extern void ResetWellKnownSockets(
183 #if NeedFunctionPrototypes
189 AuthorizationIDOfClient(
190 #if NeedFunctionPrototypes
195 extern char *ClientAuthorized(
196 #if NeedFunctionPrototypes
197 ClientPtr /*client*/,
198 unsigned int /*proto_n*/,
199 char* /*auth_proto*/,
200 unsigned int /*string_n*/,
201 char* /*auth_string*/
205 extern Bool EstablishNewConnections(
206 #if NeedFunctionPrototypes
207 ClientPtr /*clientUnused*/,
212 extern void CheckConnections(
213 #if NeedFunctionPrototypes
218 extern void CloseDownConnection(
219 #if NeedFunctionPrototypes
224 extern int AddEnabledDevice(
225 #if NeedFunctionPrototypes
230 extern int RemoveEnabledDevice(
231 #if NeedFunctionPrototypes
236 extern int OnlyListenToOneClient(
237 #if NeedFunctionPrototypes
242 extern int ListenToAllClients(
243 #if NeedFunctionPrototypes
248 extern int IgnoreClient(
249 #if NeedFunctionPrototypes
254 extern int AttendClient(
255 #if NeedFunctionPrototypes
260 extern int MakeClientGrabImpervious(
261 #if NeedFunctionPrototypes
266 extern int MakeClientGrabPervious(
267 #if NeedFunctionPrototypes
273 #if NeedFunctionPrototypes
278 extern CARD32 GetTimeInMillis(
279 #if NeedFunctionPrototypes
284 extern int AdjustWaitForDelay(
285 #if NeedFunctionPrototypes
286 pointer /*waitTime*/,
287 unsigned long /*newdelay*/
291 typedef struct _OsTimerRec *OsTimerPtr;
293 typedef CARD32 (*OsTimerCallback)(
294 #if NeedFunctionPrototypes
295 OsTimerPtr /* timer */,
301 extern void TimerInit(
302 #if NeedFunctionPrototypes
307 extern Bool TimerForce(
308 #if NeedFunctionPrototypes
309 OsTimerPtr /* timer */
313 #define TimerAbsolute (1<<0)
314 #define TimerForceOld (1<<1)
316 extern OsTimerPtr TimerSet(
317 #if NeedFunctionPrototypes
318 OsTimerPtr /* timer */,
321 OsTimerCallback /* func */,
326 extern void TimerCheck(
327 #if NeedFunctionPrototypes
332 extern void TimerCancel(
333 #if NeedFunctionPrototypes
334 OsTimerPtr /* pTimer */
338 extern void TimerFree(
339 #if NeedFunctionPrototypes
340 OsTimerPtr /* pTimer */
344 extern SIGVAL AutoResetServer(
345 #if NeedFunctionPrototypes
350 extern SIGVAL GiveUp(
351 #if NeedFunctionPrototypes
357 #if NeedFunctionPrototypes
362 extern void ProcessCommandLine(
363 #if NeedFunctionPrototypes
369 extern unsigned long *Xalloc(
370 #if NeedFunctionPrototypes
371 unsigned long /*amount*/
375 extern unsigned long *XNFalloc(
376 #if NeedFunctionPrototypes
377 unsigned long /*amount*/
381 extern unsigned long *Xcalloc(
382 #if NeedFunctionPrototypes
383 unsigned long /*amount*/
387 extern unsigned long *Xrealloc(
388 #if NeedFunctionPrototypes
390 unsigned long /*amount*/
394 extern unsigned long *XNFrealloc(
395 #if NeedFunctionPrototypes
397 unsigned long /*amount*/
402 #if NeedFunctionPrototypes
407 extern void OsInitAllocator(
408 #if NeedFunctionPrototypes
413 typedef SIGVAL (*OsSigHandlerPtr)(
414 #if NeedFunctionPrototypes
419 extern OsSigHandlerPtr OsSignal(
420 #if NeedFunctionPrototypes
422 OsSigHandlerPtr /* handler */
426 extern int auditTrailLevel;
429 #if NeedVarargsPrototypes
435 extern void FatalError(
436 #if NeedVarargsPrototypes
441 #if __GNUC__ == 2 && __GNUC_MINOR__ > 4
442 __attribute((noreturn))
447 #if NeedVarargsPrototypes
454 extern void LockServer(
455 #if NeedFunctionPrototypes
460 extern void UnlockServer(
461 #if NeedFunctionPrototypes
467 extern int OsLookupColor(
468 #if NeedFunctionPrototypes
472 unsigned short * /*pred*/,
473 unsigned short * /*pgreen*/,
474 unsigned short * /*pblue*/
479 #if NeedFunctionPrototypes
484 extern void OsCleanup(
485 #if NeedFunctionPrototypes
490 extern void OsVendorFatalError(
491 #if NeedFunctionPrototypes
496 extern void OsVendorInit(
497 #if NeedFunctionPrototypes
502 extern int OsInitColors(
503 #if NeedFunctionPrototypes
508 #if !defined(WIN32) && !defined(__EMX__)
510 #if NeedFunctionPrototypes
515 extern pointer Popen(
516 #if NeedFunctionPrototypes
523 #if NeedFunctionPrototypes
528 #define System(a) system(a)
529 #define Popen(a,b) popen(a,b)
530 #define Pclose(a) pclose(a)
534 #if NeedFunctionPrototypes
535 ClientPtr /*client*/,
542 extern Bool ForEachHostInFamily (
543 #if NeedFunctionPrototypes
546 #if NeedNestedPrototypes
547 unsigned char * /* addr */,
549 pointer /* closure */
556 extern int RemoveHost(
557 #if NeedFunctionPrototypes
558 ClientPtr /*client*/,
566 #if NeedFunctionPrototypes
574 typedef struct sockaddr * sockaddrPtr;
576 extern int InvalidHost(
577 #if NeedFunctionPrototypes
578 sockaddrPtr /*saddr*/,
583 extern int LocalClient(
584 #if NeedFunctionPrototypes
585 ClientPtr /* client */
589 extern int ChangeAccessControl(
590 #if NeedFunctionPrototypes
591 ClientPtr /*client*/,
596 extern int GetAccessControl(
597 #if NeedFunctionPrototypes
603 extern void AddLocalHosts(
604 #if NeedFunctionPrototypes
609 extern void ResetHosts(
610 #if NeedFunctionPrototypes
615 extern void EnableLocalHost(
616 #if NeedFunctionPrototypes
621 extern void DisableLocalHost(
622 #if NeedFunctionPrototypes
627 extern void AccessUsingXdmcp(
628 #if NeedFunctionPrototypes
633 extern void DefineSelf(
634 #if NeedFunctionPrototypes
639 extern void AugmentSelf(
640 #if NeedFunctionPrototypes
646 extern void InitAuthorization(
647 #if NeedFunctionPrototypes
652 extern int LoadAuthorization(
653 #if NeedFunctionPrototypes
658 extern void RegisterAuthorizations(
659 #if NeedFunctionPrototypes
664 extern XID CheckAuthorization(
665 #if NeedFunctionPrototypes
666 unsigned int /*namelength*/,
668 unsigned int /*datalength*/,
670 ClientPtr /*client*/,
675 extern void ResetAuthorization(
676 #if NeedFunctionPrototypes
681 extern int AddAuthorization(
682 #if NeedFunctionPrototypes
683 unsigned int /*name_length*/,
685 unsigned int /*data_length*/,
690 extern XID GenerateAuthorization(
691 #if NeedFunctionPrototypes
692 unsigned int /* name_length */,
694 unsigned int /* data_length */,
696 unsigned int * /* data_length_return */,
697 char ** /* data_return */
701 extern void ExpandCommandLine(
702 #if NeedFunctionPrototypes
708 extern int ddxProcessArgument(
709 #if NeedFunctionPrototypes
717 * idiom processing stuff
720 xReqPtr PeekNextRequest(
721 #if NeedFunctionPrototypes
722 xReqPtr req, ClientPtr client, Bool readmore
727 #if NeedFunctionPrototypes
728 xReqPtr req, ClientPtr client, int numskipped
732 /* int ReqLen(xReq *req, ClientPtr client)
733 * Given a pointer to a *complete* request, return its length in bytes.
734 * Note that if the request is a big request (as defined in the Big
735 * Requests extension), the macro lies by returning 4 less than the
736 * length that it actually occupies in the request buffer. This is so you
737 * can blindly compare the length with the various sz_<request> constants
738 * in Xproto.h without having to know/care about big requests.
740 #define ReqLen(_pxReq, _client) \
742 (_client->swapped ? lswaps(_pxReq->length) : _pxReq->length) \
743 : ((_client->swapped ? \
744 lswapl(((CARD32*)_pxReq)[1]) : ((CARD32*)_pxReq)[1])-1) \
747 /* otherReqTypePtr CastxReq(xReq *req, otherReqTypePtr)
748 * Cast the given request to one of type otherReqTypePtr to access
749 * fields beyond the length field.
751 #define CastxReq(_pxReq, otherReqTypePtr) \
752 (_pxReq->length ? (otherReqTypePtr)_pxReq \
753 : (otherReqTypePtr)(((CARD32*)_pxReq)+1))
755 /* stuff for SkippedRequestsCallback */
756 extern CallbackListPtr SkippedRequestsCallback;
761 } SkippedRequestInfoRec;
763 /* stuff for ReplyCallback */
764 extern CallbackListPtr ReplyCallback;
768 unsigned long dataLenBytes;
769 unsigned long bytesRemaining;
773 /* stuff for FlushCallback */
774 extern CallbackListPtr FlushCallback;