1
/* $XFree86: xc/programs/Xserver/include/os.h,v 3.43 2002/12/24 17:42:59 tsi Exp $ */
2
/***********************************************************
4
Copyright 1987, 1998 The Open Group
6
Permission to use, copy, modify, distribute, and sell this software and its
7
documentation for any purpose is hereby granted without fee, provided that
8
the above copyright notice appear in all copies and that both that
9
copyright notice and this permission notice appear in supporting
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
OPEN GROUP 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 Open Group 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 Open Group.
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
/* $Xorg: os.h,v 1.4 2001/02/09 02:05:15 xorgcvs Exp $ */
54
#define ALLOCATE_LOCAL_FALLBACK(_size) Xalloc((unsigned long)(_size))
55
#define DEALLOCATE_LOCAL_FALLBACK(_ptr) Xfree((pointer)(_ptr))
60
#include "xf86_ansic.h"
63
#define NullFID ((FID) 0)
65
#define SCREEN_SAVER_ON 0
66
#define SCREEN_SAVER_OFF 1
67
#define SCREEN_SAVER_FORCER 2
68
#define SCREEN_SAVER_CYCLE 3
70
#ifndef MAX_REQUEST_SIZE
71
#define MAX_REQUEST_SIZE 65535
73
#ifndef MAX_BIG_REQUEST_SIZE
74
#define MAX_BIG_REQUEST_SIZE 1048575
78
typedef struct _FontPathRec *FontPathPtr;
79
typedef struct _NewClientRec *NewClientPtr;
82
#define xnfalloc(size) XNFalloc((unsigned long)(size))
83
#define xnfcalloc(_num, _size) XNFcalloc((unsigned long)(_num)*(unsigned long)(_size))
84
#define xnfrealloc(ptr, size) XNFrealloc((pointer)(ptr), (unsigned long)(size))
86
#define xalloc(size) Xalloc((unsigned long)(size))
87
#define xcalloc(_num, _size) Xcalloc((unsigned long)(_num)*(unsigned long)(_size))
88
#define xrealloc(ptr, size) Xrealloc((pointer)(ptr), (unsigned long)(size))
89
#define xfree(ptr) Xfree((pointer)(ptr))
90
#define xstrdup(s) Xstrdup(s)
91
#define xnfstrdup(s) XNFstrdup(s)
101
/* have to put $(SIGNAL_DEFINES) in DEFINES in Imakefile to get this right */
102
#ifdef SIGNALRETURNSINT
108
extern Bool OsDelayInitColors;
109
extern void (*OsVendorVErrorFProc)(const char *, va_list args);
111
extern int WaitForSomething(
112
#if NeedFunctionPrototypes
113
int* /*pClientsReady*/
118
#define ReadRequestFromClient(client) ((client)->readRequest(client))
119
extern int StandardReadRequestFromClient(
120
#if NeedFunctionPrototypes
125
extern int ClientConnectionNumber(
126
#if NeedFunctionPrototypes
131
extern int ReadRequestFromClient(
132
#if NeedFunctionPrototypes
138
extern Bool InsertFakeRequest(
139
#if NeedFunctionPrototypes
140
ClientPtr /*client*/,
146
extern void ResetCurrentRequest(
147
#if NeedFunctionPrototypes
152
extern void FlushAllOutput(
153
#if NeedFunctionPrototypes
158
extern void FlushIfCriticalOutputPending(
159
#if NeedFunctionPrototypes
164
extern void SetCriticalOutputPending(
165
#if NeedFunctionPrototypes
170
extern int WriteToClient(
171
#if NeedFunctionPrototypes
178
extern void ResetOsBuffers(
179
#if NeedFunctionPrototypes
184
extern void InitConnectionLimits(
185
#if NeedFunctionPrototypes
190
extern void CreateWellKnownSockets(
191
#if NeedFunctionPrototypes
196
extern void ResetWellKnownSockets(
197
#if NeedFunctionPrototypes
202
extern void CloseWellKnownConnections(
203
#if NeedFunctionPrototypes
209
AuthorizationIDOfClient(
210
#if NeedFunctionPrototypes
215
extern char *ClientAuthorized(
216
#if NeedFunctionPrototypes
217
ClientPtr /*client*/,
218
unsigned int /*proto_n*/,
219
char* /*auth_proto*/,
220
unsigned int /*string_n*/,
221
char* /*auth_string*/
225
extern Bool EstablishNewConnections(
226
#if NeedFunctionPrototypes
227
ClientPtr /*clientUnused*/,
232
extern void CheckConnections(
233
#if NeedFunctionPrototypes
238
extern void CloseDownConnection(
239
#if NeedFunctionPrototypes
244
extern void AddEnabledDevice(
245
#if NeedFunctionPrototypes
250
extern void RemoveEnabledDevice(
251
#if NeedFunctionPrototypes
256
extern void OnlyListenToOneClient(
257
#if NeedFunctionPrototypes
262
extern void ListenToAllClients(
263
#if NeedFunctionPrototypes
268
extern void IgnoreClient(
269
#if NeedFunctionPrototypes
274
extern void AttendClient(
275
#if NeedFunctionPrototypes
280
extern void MakeClientGrabImpervious(
281
#if NeedFunctionPrototypes
286
extern void MakeClientGrabPervious(
287
#if NeedFunctionPrototypes
293
extern void CloseDownFileDescriptor(
294
#if NeedFunctionPrototypes
295
ClientPtr /* client */
300
extern void AvailableClientInput(
301
#if NeedFunctionPrototypes
302
ClientPtr /* client */
307
#if NeedFunctionPrototypes
312
extern CARD32 GetTimeInMillis(
313
#if NeedFunctionPrototypes
318
extern void AdjustWaitForDelay(
319
#if NeedFunctionPrototypes
320
pointer /*waitTime*/,
321
unsigned long /*newdelay*/
325
typedef struct _OsTimerRec *OsTimerPtr;
327
typedef CARD32 (*OsTimerCallback)(
328
#if NeedFunctionPrototypes
329
OsTimerPtr /* timer */,
335
extern void TimerInit(
336
#if NeedFunctionPrototypes
341
extern Bool TimerForce(
342
#if NeedFunctionPrototypes
343
OsTimerPtr /* timer */
347
#define TimerAbsolute (1<<0)
348
#define TimerForceOld (1<<1)
350
extern OsTimerPtr TimerSet(
351
#if NeedFunctionPrototypes
352
OsTimerPtr /* timer */,
355
OsTimerCallback /* func */,
360
extern void TimerCheck(
361
#if NeedFunctionPrototypes
366
extern void TimerCancel(
367
#if NeedFunctionPrototypes
368
OsTimerPtr /* pTimer */
372
extern void TimerFree(
373
#if NeedFunctionPrototypes
374
OsTimerPtr /* pTimer */
378
extern SIGVAL AutoResetServer(
379
#if NeedFunctionPrototypes
384
extern SIGVAL GiveUp(
385
#if NeedFunctionPrototypes
391
#if NeedFunctionPrototypes
396
extern void ProcessCommandLine(
397
#if NeedFunctionPrototypes
403
extern pointer Xalloc(
404
#if NeedFunctionPrototypes
405
unsigned long /*amount*/
409
extern pointer XNFalloc(
410
#if NeedFunctionPrototypes
411
unsigned long /*amount*/
415
extern pointer Xcalloc(
416
#if NeedFunctionPrototypes
417
unsigned long /*amount*/
421
extern pointer XNFcalloc(
422
#if NeedFunctionPrototypes
423
unsigned long /*amount*/
427
extern pointer Xrealloc(
428
#if NeedFunctionPrototypes
430
unsigned long /*amount*/
434
extern pointer XNFrealloc(
435
#if NeedFunctionPrototypes
437
unsigned long /*amount*/
442
#if NeedFunctionPrototypes
447
extern void OsInitAllocator(
448
#if NeedFunctionPrototypes
453
extern char *Xstrdup(const char *s);
454
extern char *XNFstrdup(const char *s);
456
typedef SIGVAL (*OsSigHandlerPtr)(
457
#if NeedFunctionPrototypes
462
extern OsSigHandlerPtr OsSignal(
463
#if NeedFunctionPrototypes
465
OsSigHandlerPtr /* handler */
469
extern int auditTrailLevel;
471
extern void AuditPrefix(
472
#if NeedFunctionPrototypes
478
#if NeedVarargsPrototypes
484
extern void FatalError(
485
#if NeedVarargsPrototypes
490
#if defined(__GNUC__) && \
491
((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ > 4)))
492
__attribute((noreturn))
497
#if NeedVarargsPrototypes
503
#if NeedVarargsPrototypes
504
extern void VErrorF(const char *f, va_list args);
508
extern void LockServer(
509
#if NeedFunctionPrototypes
514
extern void UnlockServer(
515
#if NeedFunctionPrototypes
521
extern int OsLookupColor(
522
#if NeedFunctionPrototypes
526
unsigned short * /*pred*/,
527
unsigned short * /*pgreen*/,
528
unsigned short * /*pblue*/
533
#if NeedFunctionPrototypes
538
extern void OsCleanup(
539
#if NeedFunctionPrototypes
544
extern void OsVendorFatalError(
545
#if NeedFunctionPrototypes
550
extern void OsVendorInit(
551
#if NeedFunctionPrototypes
556
extern int OsInitColors(
557
#if NeedFunctionPrototypes
562
void OsBlockSignals (
563
#if NeedFunctionPrototypes
568
void OsReleaseSignals (
569
#if NeedFunctionPrototypes
574
#if !defined(WIN32) && !defined(__UNIXOS2__)
575
extern int System(char *);
576
extern pointer Popen(char *, char *);
577
extern int Pclose(pointer);
579
#define System(a) system(a)
580
#define Popen(a,b) popen(a,b)
581
#define Pclose(a) pclose(a)
584
extern void CheckUserParameters(int argc, char **argv, char **envp);
585
extern void CheckUserAuthorization(void);
588
#if NeedFunctionPrototypes
589
ClientPtr /*client*/,
596
extern Bool ForEachHostInFamily (
597
#if NeedFunctionPrototypes
600
#if NeedNestedPrototypes
601
unsigned char * /* addr */,
603
pointer /* closure */
610
extern int RemoveHost(
611
#if NeedFunctionPrototypes
612
ClientPtr /*client*/,
620
#if NeedFunctionPrototypes
628
typedef struct sockaddr * sockaddrPtr;
630
extern int InvalidHost(
631
#if NeedFunctionPrototypes
632
sockaddrPtr /*saddr*/,
637
extern int LocalClient(
638
#if NeedFunctionPrototypes
639
ClientPtr /* client */
643
extern int LocalClientCred(ClientPtr, int *, int *);
645
extern int ChangeAccessControl(
646
#if NeedFunctionPrototypes
647
ClientPtr /*client*/,
652
extern int GetAccessControl(
653
#if NeedFunctionPrototypes
659
extern void AddLocalHosts(
660
#if NeedFunctionPrototypes
665
extern void ResetHosts(
666
#if NeedFunctionPrototypes
671
extern void EnableLocalHost(
672
#if NeedFunctionPrototypes
677
extern void DisableLocalHost(
678
#if NeedFunctionPrototypes
683
extern void AccessUsingXdmcp(
684
#if NeedFunctionPrototypes
689
extern void DefineSelf(
690
#if NeedFunctionPrototypes
695
extern void AugmentSelf(
696
#if NeedFunctionPrototypes
702
extern void InitAuthorization(
703
#if NeedFunctionPrototypes
708
extern int LoadAuthorization(
709
#if NeedFunctionPrototypes
714
extern void RegisterAuthorizations(
715
#if NeedFunctionPrototypes
720
extern XID AuthorizationToID (
721
unsigned short name_length,
723
unsigned short data_length,
726
extern int AuthorizationFromID (
728
unsigned short *name_lenp,
730
unsigned short *data_lenp,
733
extern XID CheckAuthorization(
734
#if NeedFunctionPrototypes
735
unsigned int /*namelength*/,
737
unsigned int /*datalength*/,
739
ClientPtr /*client*/,
744
extern void ResetAuthorization(
745
#if NeedFunctionPrototypes
750
extern int RemoveAuthorization (
751
unsigned short name_length,
753
unsigned short data_length,
756
extern int AddAuthorization(
757
#if NeedFunctionPrototypes
758
unsigned int /*name_length*/,
760
unsigned int /*data_length*/,
765
extern XID GenerateAuthorization(
766
#if NeedFunctionPrototypes
767
unsigned int /* name_length */,
769
unsigned int /* data_length */,
771
unsigned int * /* data_length_return */,
772
char ** /* data_return */
776
#ifdef COMMANDLINE_CHALLENGED_OPERATING_SYSTEMS
777
extern void ExpandCommandLine(
778
#if NeedFunctionPrototypes
785
extern int ddxProcessArgument(
786
#if NeedFunctionPrototypes
793
extern void ddxUseMsg(void);
796
* idiom processing stuff
799
xReqPtr PeekNextRequest(
800
#if NeedFunctionPrototypes
801
xReqPtr req, ClientPtr client, Bool readmore
806
#if NeedFunctionPrototypes
807
xReqPtr req, ClientPtr client, int numskipped
811
/* int ReqLen(xReq *req, ClientPtr client)
812
* Given a pointer to a *complete* request, return its length in bytes.
813
* Note that if the request is a big request (as defined in the Big
814
* Requests extension), the macro lies by returning 4 less than the
815
* length that it actually occupies in the request buffer. This is so you
816
* can blindly compare the length with the various sz_<request> constants
817
* in Xproto.h without having to know/care about big requests.
819
#define ReqLen(_pxReq, _client) \
821
(_client->swapped ? lswaps(_pxReq->length) : _pxReq->length) \
822
: ((_client->swapped ? \
823
lswapl(((CARD32*)_pxReq)[1]) : ((CARD32*)_pxReq)[1])-1) \
826
/* otherReqTypePtr CastxReq(xReq *req, otherReqTypePtr)
827
* Cast the given request to one of type otherReqTypePtr to access
828
* fields beyond the length field.
830
#define CastxReq(_pxReq, otherReqTypePtr) \
831
(_pxReq->length ? (otherReqTypePtr)_pxReq \
832
: (otherReqTypePtr)(((CARD32*)_pxReq)+1))
834
/* stuff for SkippedRequestsCallback */
835
extern CallbackListPtr SkippedRequestsCallback;
840
} SkippedRequestInfoRec;
842
/* stuff for ReplyCallback */
843
extern CallbackListPtr ReplyCallback;
847
unsigned long dataLenBytes;
848
unsigned long bytesRemaining;
852
/* stuff for FlushCallback */
853
extern CallbackListPtr FlushCallback;
855
extern void AbortDDX(void);
856
extern void ddxGiveUp(void);
857
extern int TimeSinceLastInputEvent(void);