VirtualBox

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

Last change on this file since 78293 was 40349, checked in by vboxsync, 13 years ago

Additions/xorg: support X.Org Server 1.12.

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