VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/x11include/xorg-server-1.9.0/os.h@ 38889

Last change on this file since 38889 was 32163, checked in by vboxsync, 14 years ago

Additions/x11/x11include: additional headers for building drivers for X.Org Server 1.9

  • Property svn:eol-style set to native
File size: 16.8 KB
Line 
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
25
26Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
27
28 All Rights Reserved
29
30Permission to use, copy, modify, and distribute this software and its
31documentation for any purpose and without fee is hereby granted,
32provided that the above copyright notice appear in all copies and that
33both that copyright notice and this permission notice appear in
34supporting documentation, and that the name of Digital not be
35used in advertising or publicity pertaining to distribution of the
36software without specific, written prior permission.
37
38DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
39ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
40DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
41ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
42WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
43ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
44SOFTWARE.
45
46******************************************************************/
47
48
49#ifndef OS_H
50#define OS_H
51
52#include "misc.h"
53#include <stdarg.h>
54
55#define SCREEN_SAVER_ON 0
56#define SCREEN_SAVER_OFF 1
57#define SCREEN_SAVER_FORCER 2
58#define SCREEN_SAVER_CYCLE 3
59
60#ifndef MAX_REQUEST_SIZE
61#define MAX_REQUEST_SIZE 65535
62#endif
63#ifndef MAX_BIG_REQUEST_SIZE
64#define MAX_BIG_REQUEST_SIZE 4194303
65#endif
66
67typedef struct _FontPathRec *FontPathPtr;
68typedef struct _NewClientRec *NewClientPtr;
69
70#ifndef xalloc
71#define xnfalloc(size) XNFalloc((unsigned long)(size))
72#define xnfcalloc(_num, _size) XNFcalloc((unsigned long)(_num)*(unsigned long)(_size))
73#define xnfrealloc(ptr, size) XNFrealloc((pointer)(ptr), (unsigned long)(size))
74
75#define xalloc(size) Xalloc((unsigned long)(size))
76#define xcalloc(_num, _size) Xcalloc((unsigned long)(_num)*(unsigned long)(_size))
77#define xrealloc(ptr, size) Xrealloc((pointer)(ptr), (unsigned long)(size))
78#define xfree(ptr) Xfree((pointer)(ptr))
79#define xstrdup(s) Xstrdup(s)
80#define xnfstrdup(s) XNFstrdup(s)
81#endif
82
83#include <stdio.h>
84#include <stdarg.h>
85
86#ifdef DDXBEFORERESET
87extern void ddxBeforeReset (void);
88#endif
89
90#ifdef DDXOSVERRORF
91extern _X_EXPORT void (*OsVendorVErrorFProc)(const char *, va_list args);
92#endif
93
94extern _X_EXPORT int WaitForSomething(
95 int* /*pClientsReady*/
96);
97
98extern _X_EXPORT int ReadRequestFromClient(ClientPtr /*client*/);
99
100extern _X_EXPORT Bool InsertFakeRequest(
101 ClientPtr /*client*/,
102 char* /*data*/,
103 int /*count*/);
104
105extern _X_EXPORT void ResetCurrentRequest(ClientPtr /*client*/);
106
107extern _X_EXPORT void FlushAllOutput(void);
108
109extern _X_EXPORT void FlushIfCriticalOutputPending(void);
110
111extern _X_EXPORT void SetCriticalOutputPending(void);
112
113extern _X_EXPORT int WriteToClient(ClientPtr /*who*/, int /*count*/, const void* /*buf*/);
114
115extern _X_EXPORT void ResetOsBuffers(void);
116
117extern _X_EXPORT void InitConnectionLimits(void);
118
119extern _X_EXPORT void NotifyParentProcess(void);
120
121extern _X_EXPORT void CreateWellKnownSockets(void);
122
123extern _X_EXPORT void ResetWellKnownSockets(void);
124
125extern _X_EXPORT void CloseWellKnownConnections(void);
126
127extern _X_EXPORT XID AuthorizationIDOfClient(ClientPtr /*client*/);
128
129extern _X_EXPORT char *ClientAuthorized(
130 ClientPtr /*client*/,
131 unsigned int /*proto_n*/,
132 char* /*auth_proto*/,
133 unsigned int /*string_n*/,
134 char* /*auth_string*/);
135
136extern _X_EXPORT Bool EstablishNewConnections(
137 ClientPtr /*clientUnused*/,
138 pointer /*closure*/);
139
140extern _X_EXPORT void CheckConnections(void);
141
142extern _X_EXPORT void CloseDownConnection(ClientPtr /*client*/);
143
144extern _X_EXPORT void AddGeneralSocket(int /*fd*/);
145
146extern _X_EXPORT void RemoveGeneralSocket(int /*fd*/);
147
148extern _X_EXPORT void AddEnabledDevice(int /*fd*/);
149
150extern _X_EXPORT void RemoveEnabledDevice(int /*fd*/);
151
152extern _X_EXPORT int OnlyListenToOneClient(ClientPtr /*client*/);
153
154extern _X_EXPORT void ListenToAllClients(void);
155
156extern _X_EXPORT void IgnoreClient(ClientPtr /*client*/);
157
158extern _X_EXPORT void AttendClient(ClientPtr /*client*/);
159
160extern _X_EXPORT void MakeClientGrabImpervious(ClientPtr /*client*/);
161
162extern _X_EXPORT void MakeClientGrabPervious(ClientPtr /*client*/);
163
164#ifdef XQUARTZ
165extern void ListenOnOpenFD(int /* fd */, int /* noxauth */);
166#endif
167
168extern _X_EXPORT CARD32 GetTimeInMillis(void);
169
170extern _X_EXPORT void AdjustWaitForDelay(
171 pointer /*waitTime*/,
172 unsigned long /*newdelay*/);
173
174typedef struct _OsTimerRec *OsTimerPtr;
175
176typedef CARD32 (*OsTimerCallback)(
177 OsTimerPtr /* timer */,
178 CARD32 /* time */,
179 pointer /* arg */);
180
181extern _X_EXPORT void TimerInit(void);
182
183extern _X_EXPORT Bool TimerForce(OsTimerPtr /* timer */);
184
185#define TimerAbsolute (1<<0)
186#define TimerForceOld (1<<1)
187
188extern _X_EXPORT OsTimerPtr TimerSet(
189 OsTimerPtr /* timer */,
190 int /* flags */,
191 CARD32 /* millis */,
192 OsTimerCallback /* func */,
193 pointer /* arg */);
194
195extern _X_EXPORT void TimerCheck(void);
196extern _X_EXPORT void TimerCancel(OsTimerPtr /* pTimer */);
197extern _X_EXPORT void TimerFree(OsTimerPtr /* pTimer */);
198
199extern _X_EXPORT void SetScreenSaverTimer(void);
200extern _X_EXPORT void FreeScreenSaverTimer(void);
201
202extern _X_EXPORT void AutoResetServer(int /*sig*/);
203
204extern _X_EXPORT void GiveUp(int /*sig*/);
205
206extern _X_EXPORT void UseMsg(void);
207
208extern _X_EXPORT void ProcessCommandLine(int /*argc*/, char* /*argv*/[]);
209
210extern _X_EXPORT int set_font_authorizations(
211 char ** /* authorizations */,
212 int * /*authlen */,
213 pointer /* client */);
214
215#ifndef _HAVE_XALLOC_DECLS
216#define _HAVE_XALLOC_DECLS
217
218/*
219 * Use malloc(3) instead.
220 */
221extern _X_EXPORT void *Xalloc(unsigned long /*amount*/) _X_DEPRECATED;
222/*
223 * Use calloc(3) instead
224 */
225extern _X_EXPORT void *Xcalloc(unsigned long /*amount*/) _X_DEPRECATED;
226/*
227 * Use realloc(3) instead
228 */
229extern _X_EXPORT void *Xrealloc(void * /*ptr*/, unsigned long /*amount*/)
230 _X_DEPRECATED;
231/*
232 * Use free(3) instead
233 */
234extern _X_EXPORT void Xfree(void * /*ptr*/) _X_DEPRECATED;
235
236#endif
237
238/*
239 * This function malloc(3)s buffer, terminating the server if there is not
240 * enough memory.
241 */
242extern _X_EXPORT void *XNFalloc(unsigned long /*amount*/);
243/*
244 * This function calloc(3)s buffer, terminating the server if there is not
245 * enough memory.
246 */
247extern _X_EXPORT void *XNFcalloc(unsigned long /*amount*/);
248/*
249 * This function realloc(3)s passed buffer, terminating the server if there is
250 * not enough memory.
251 */
252extern _X_EXPORT void *XNFrealloc(void * /*ptr*/, unsigned long /*amount*/);
253
254/*
255 * This function strdup(3)s passed string. The only difference from the library
256 * function that it is safe to pass NULL, as NULL will be returned.
257 */
258extern _X_EXPORT char *Xstrdup(const char *s);
259
260/*
261 * This function strdup(3)s passed string, terminating the server if there is
262 * not enough memory. If NULL is passed to this function, NULL is returned.
263 */
264extern _X_EXPORT char *XNFstrdup(const char *s);
265
266extern _X_EXPORT char *Xprintf(const char *fmt, ...) _X_ATTRIBUTE_PRINTF(1,2);
267extern _X_EXPORT char *Xvprintf(const char *fmt, va_list va);
268extern _X_EXPORT char *XNFprintf(const char *fmt, ...) _X_ATTRIBUTE_PRINTF(1,2);
269extern _X_EXPORT char *XNFvprintf(const char *fmt, va_list va);
270
271typedef void (*OsSigHandlerPtr)(int /* sig */);
272typedef int (*OsSigWrapperPtr)(int /* sig */);
273
274extern _X_EXPORT OsSigHandlerPtr OsSignal(int /* sig */, OsSigHandlerPtr /* handler */);
275extern _X_EXPORT OsSigWrapperPtr OsRegisterSigWrapper(OsSigWrapperPtr newWrap);
276
277extern _X_EXPORT int auditTrailLevel;
278
279extern _X_EXPORT void LockServer(void);
280extern _X_EXPORT void UnlockServer(void);
281
282extern _X_EXPORT int OsLookupColor(
283 int /*screen*/,
284 char * /*name*/,
285 unsigned /*len*/,
286 unsigned short * /*pred*/,
287 unsigned short * /*pgreen*/,
288 unsigned short * /*pblue*/);
289
290extern _X_EXPORT void OsInit(void);
291
292extern _X_EXPORT void OsCleanup(Bool);
293
294extern _X_EXPORT void OsVendorFatalError(void);
295
296extern _X_EXPORT void OsVendorInit(void);
297
298extern _X_EXPORT void OsBlockSignals (void);
299
300extern _X_EXPORT void OsReleaseSignals (void);
301
302extern _X_EXPORT void OsAbort (void) _X_NORETURN;
303
304#if !defined(WIN32)
305extern _X_EXPORT int System(char *);
306extern _X_EXPORT pointer Popen(char *, char *);
307extern _X_EXPORT int Pclose(pointer);
308extern _X_EXPORT pointer Fopen(char *, char *);
309extern _X_EXPORT int Fclose(pointer);
310#else
311#define System(a) system(a)
312#define Popen(a,b) popen(a,b)
313#define Pclose(a) pclose(a)
314#define Fopen(a,b) fopen(a,b)
315#define Fclose(a) fclose(a)
316#endif
317
318extern _X_EXPORT void CheckUserParameters(int argc, char **argv, char **envp);
319extern _X_EXPORT void CheckUserAuthorization(void);
320
321extern _X_EXPORT int AddHost(
322 ClientPtr /*client*/,
323 int /*family*/,
324 unsigned /*length*/,
325 const void */*pAddr*/);
326
327extern _X_EXPORT Bool ForEachHostInFamily (
328 int /*family*/,
329 Bool (* /*func*/ )(
330 unsigned char * /* addr */,
331 short /* len */,
332 pointer /* closure */),
333 pointer /*closure*/);
334
335extern _X_EXPORT int RemoveHost(
336 ClientPtr /*client*/,
337 int /*family*/,
338 unsigned /*length*/,
339 pointer /*pAddr*/);
340
341extern _X_EXPORT int GetHosts(
342 pointer * /*data*/,
343 int * /*pnHosts*/,
344 int * /*pLen*/,
345 BOOL * /*pEnabled*/);
346
347typedef struct sockaddr * sockaddrPtr;
348
349extern _X_EXPORT int InvalidHost(sockaddrPtr /*saddr*/, int /*len*/, ClientPtr client);
350
351extern _X_EXPORT int LocalClient(ClientPtr /* client */);
352
353extern _X_EXPORT int LocalClientCred(ClientPtr, int *, int *);
354
355#define LCC_UID_SET (1 << 0)
356#define LCC_GID_SET (1 << 1)
357#define LCC_PID_SET (1 << 2)
358#define LCC_ZID_SET (1 << 3)
359
360typedef struct {
361 int fieldsSet; /* Bit mask of fields set */
362 int euid; /* Effective uid */
363 int egid; /* Primary effective group id */
364 int nSuppGids; /* Number of supplementary group ids */
365 int *pSuppGids; /* Array of supplementary group ids */
366 int pid; /* Process id */
367 int zoneid; /* Only set on Solaris 10 & later */
368} LocalClientCredRec;
369
370extern _X_EXPORT int GetLocalClientCreds(ClientPtr, LocalClientCredRec **);
371extern _X_EXPORT void FreeLocalClientCreds(LocalClientCredRec *);
372
373extern _X_EXPORT int ChangeAccessControl(ClientPtr /*client*/, int /*fEnabled*/);
374
375extern _X_EXPORT int GetAccessControl(void);
376
377
378extern _X_EXPORT void AddLocalHosts(void);
379
380extern _X_EXPORT void ResetHosts(char *display);
381
382extern _X_EXPORT void EnableLocalHost(void);
383
384extern _X_EXPORT void DisableLocalHost(void);
385
386extern _X_EXPORT void AccessUsingXdmcp(void);
387
388extern _X_EXPORT void DefineSelf(int /*fd*/);
389
390#if XDMCP
391extern _X_EXPORT void AugmentSelf(pointer /*from*/, int /*len*/);
392
393extern _X_EXPORT void RegisterAuthorizations(void);
394#endif
395
396extern _X_EXPORT void InitAuthorization(char * /*filename*/);
397
398/* extern int LoadAuthorization(void); */
399
400extern _X_EXPORT int AuthorizationFromID (
401 XID id,
402 unsigned short *name_lenp,
403 char **namep,
404 unsigned short *data_lenp,
405 char **datap);
406
407extern _X_EXPORT XID CheckAuthorization(
408 unsigned int /*namelength*/,
409 const char * /*name*/,
410 unsigned int /*datalength*/,
411 const char * /*data*/,
412 ClientPtr /*client*/,
413 char ** /*reason*/
414);
415
416extern _X_EXPORT void ResetAuthorization(void);
417
418extern _X_EXPORT int RemoveAuthorization (
419 unsigned short name_length,
420 const char *name,
421 unsigned short data_length,
422 const char *data);
423
424extern _X_EXPORT int AddAuthorization(
425 unsigned int /*name_length*/,
426 const char * /*name*/,
427 unsigned int /*data_length*/,
428 char * /*data*/);
429
430#ifdef XCSECURITY
431extern _X_EXPORT XID GenerateAuthorization(
432 unsigned int /* name_length */,
433 const char * /* name */,
434 unsigned int /* data_length */,
435 const char * /* data */,
436 unsigned int * /* data_length_return */,
437 char ** /* data_return */);
438#endif
439
440extern _X_EXPORT int ddxProcessArgument(int /*argc*/, char * /*argv*/ [], int /*i*/);
441
442extern _X_EXPORT void ddxUseMsg(void);
443
444/* int ReqLen(xReq *req, ClientPtr client)
445 * Given a pointer to a *complete* request, return its length in bytes.
446 * Note that if the request is a big request (as defined in the Big
447 * Requests extension), the macro lies by returning 4 less than the
448 * length that it actually occupies in the request buffer. This is so you
449 * can blindly compare the length with the various sz_<request> constants
450 * in Xproto.h without having to know/care about big requests.
451 */
452#define ReqLen(_pxReq, _client) \
453 ((_pxReq->length ? \
454 (_client->swapped ? lswaps(_pxReq->length) : _pxReq->length) \
455 : ((_client->swapped ? \
456 lswapl(((CARD32*)_pxReq)[1]) : ((CARD32*)_pxReq)[1])-1) \
457 ) << 2)
458
459/* otherReqTypePtr CastxReq(xReq *req, otherReqTypePtr)
460 * Cast the given request to one of type otherReqTypePtr to access
461 * fields beyond the length field.
462 */
463#define CastxReq(_pxReq, otherReqTypePtr) \
464 (_pxReq->length ? (otherReqTypePtr)_pxReq \
465 : (otherReqTypePtr)(((CARD32*)_pxReq)+1))
466
467/* stuff for ReplyCallback */
468extern _X_EXPORT CallbackListPtr ReplyCallback;
469typedef struct {
470 ClientPtr client;
471 const void *replyData;
472 unsigned long dataLenBytes;
473 unsigned long bytesRemaining;
474 Bool startOfReply;
475} ReplyInfoRec;
476
477/* stuff for FlushCallback */
478extern _X_EXPORT CallbackListPtr FlushCallback;
479
480extern _X_EXPORT void AbortDDX(void);
481extern _X_EXPORT void ddxGiveUp(void);
482extern _X_EXPORT int TimeSinceLastInputEvent(void);
483
484/* strcasecmp.c */
485#if NEED_STRCASECMP
486#define strcasecmp xstrcasecmp
487extern _X_EXPORT int xstrcasecmp(const char *s1, const char *s2);
488#endif
489
490#if NEED_STRNCASECMP
491#define strncasecmp xstrncasecmp
492extern _X_EXPORT int xstrncasecmp(const char *s1, const char *s2, size_t n);
493#endif
494
495#if NEED_STRCASESTR
496#define strcasestr xstrcasestr
497extern _X_EXPORT char *xstrcasestr(const char *s, const char *find);
498#endif
499
500#ifndef HAS_STRLCPY
501extern _X_EXPORT size_t strlcpy(char *dst, const char *src, size_t siz);
502extern _X_EXPORT size_t strlcat(char *dst, const char *src, size_t siz);
503#endif
504
505/* Logging. */
506typedef enum _LogParameter {
507 XLOG_FLUSH,
508 XLOG_SYNC,
509 XLOG_VERBOSITY,
510 XLOG_FILE_VERBOSITY
511} LogParameter;
512
513/* Flags for log messages. */
514typedef enum {
515 X_PROBED, /* Value was probed */
516 X_CONFIG, /* Value was given in the config file */
517 X_DEFAULT, /* Value is a default */
518 X_CMDLINE, /* Value was given on the command line */
519 X_NOTICE, /* Notice */
520 X_ERROR, /* Error message */
521 X_WARNING, /* Warning message */
522 X_INFO, /* Informational message */
523 X_NONE, /* No prefix */
524 X_NOT_IMPLEMENTED, /* Not implemented */
525 X_UNKNOWN = -1 /* unknown -- this must always be last */
526} MessageType;
527
528extern _X_EXPORT const char *LogInit(const char *fname, const char *backup);
529extern _X_EXPORT void LogClose(void);
530extern _X_EXPORT Bool LogSetParameter(LogParameter param, int value);
531extern _X_EXPORT void LogVWrite(int verb, const char *f, va_list args);
532extern _X_EXPORT void LogWrite(int verb, const char *f, ...) _X_ATTRIBUTE_PRINTF(2,3);
533extern _X_EXPORT void LogVMessageVerb(MessageType type, int verb, const char *format,
534 va_list args);
535extern _X_EXPORT void LogMessageVerb(MessageType type, int verb, const char *format,
536 ...) _X_ATTRIBUTE_PRINTF(3,4);
537extern _X_EXPORT void LogMessage(MessageType type, const char *format, ...)
538 _X_ATTRIBUTE_PRINTF(2,3);
539extern _X_EXPORT void FreeAuditTimer(void);
540extern _X_EXPORT void AuditF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2);
541extern _X_EXPORT void VAuditF(const char *f, va_list args);
542extern _X_EXPORT void FatalError(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2) _X_NORETURN;
543
544#ifdef DEBUG
545#define DebugF ErrorF
546#else
547#define DebugF(...) /* */
548#endif
549
550extern _X_EXPORT void VErrorF(const char *f, va_list args);
551extern _X_EXPORT void ErrorF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2);
552extern _X_EXPORT void Error(char *str);
553extern _X_EXPORT void LogPrintMarkers(void);
554
555extern _X_EXPORT void xorg_backtrace(void);
556
557#endif /* OS_H */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette