VirtualBox

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

Last change on this file since 86603 was 28062, checked in by vboxsync, 15 years ago

Additions/x11/x11include: header files for building X.Org server 1.8 drivers

  • Property svn:eol-style set to native
File size: 16.2 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
217extern _X_EXPORT pointer Xalloc(unsigned long /*amount*/);
218extern _X_EXPORT pointer Xcalloc(unsigned long /*amount*/);
219extern _X_EXPORT pointer Xrealloc(pointer /*ptr*/, unsigned long /*amount*/);
220extern _X_EXPORT void Xfree(pointer /*ptr*/);
221#endif
222
223extern _X_EXPORT pointer XNFalloc(unsigned long /*amount*/);
224extern _X_EXPORT pointer XNFcalloc(unsigned long /*amount*/);
225extern _X_EXPORT pointer XNFrealloc(pointer /*ptr*/, unsigned long /*amount*/);
226
227extern _X_EXPORT char *Xstrdup(const char *s);
228extern _X_EXPORT char *XNFstrdup(const char *s);
229extern _X_EXPORT char *Xprintf(const char *fmt, ...);
230extern _X_EXPORT char *Xvprintf(const char *fmt, va_list va);
231extern _X_EXPORT char *XNFprintf(const char *fmt, ...);
232extern _X_EXPORT char *XNFvprintf(const char *fmt, va_list va);
233
234typedef void (*OsSigHandlerPtr)(int /* sig */);
235typedef int (*OsSigWrapperPtr)(int /* sig */);
236
237extern _X_EXPORT OsSigHandlerPtr OsSignal(int /* sig */, OsSigHandlerPtr /* handler */);
238extern _X_EXPORT OsSigWrapperPtr OsRegisterSigWrapper(OsSigWrapperPtr newWrap);
239
240extern _X_EXPORT int auditTrailLevel;
241
242extern _X_EXPORT void LockServer(void);
243extern _X_EXPORT void UnlockServer(void);
244
245extern _X_EXPORT int OsLookupColor(
246 int /*screen*/,
247 char * /*name*/,
248 unsigned /*len*/,
249 unsigned short * /*pred*/,
250 unsigned short * /*pgreen*/,
251 unsigned short * /*pblue*/);
252
253extern _X_EXPORT void OsInit(void);
254
255extern _X_EXPORT void OsCleanup(Bool);
256
257extern _X_EXPORT void OsVendorFatalError(void);
258
259extern _X_EXPORT void OsVendorInit(void);
260
261extern _X_EXPORT void OsBlockSignals (void);
262
263extern _X_EXPORT void OsReleaseSignals (void);
264
265extern _X_EXPORT void OsAbort (void);
266
267#if !defined(WIN32)
268extern _X_EXPORT int System(char *);
269extern _X_EXPORT pointer Popen(char *, char *);
270extern _X_EXPORT int Pclose(pointer);
271extern _X_EXPORT pointer Fopen(char *, char *);
272extern _X_EXPORT int Fclose(pointer);
273#else
274#define System(a) system(a)
275#define Popen(a,b) popen(a,b)
276#define Pclose(a) pclose(a)
277#define Fopen(a,b) fopen(a,b)
278#define Fclose(a) fclose(a)
279#endif
280
281extern _X_EXPORT void CheckUserParameters(int argc, char **argv, char **envp);
282extern _X_EXPORT void CheckUserAuthorization(void);
283
284extern _X_EXPORT int AddHost(
285 ClientPtr /*client*/,
286 int /*family*/,
287 unsigned /*length*/,
288 pointer /*pAddr*/);
289
290extern _X_EXPORT Bool ForEachHostInFamily (
291 int /*family*/,
292 Bool (* /*func*/ )(
293 unsigned char * /* addr */,
294 short /* len */,
295 pointer /* closure */),
296 pointer /*closure*/);
297
298extern _X_EXPORT int RemoveHost(
299 ClientPtr /*client*/,
300 int /*family*/,
301 unsigned /*length*/,
302 pointer /*pAddr*/);
303
304extern _X_EXPORT int GetHosts(
305 pointer * /*data*/,
306 int * /*pnHosts*/,
307 int * /*pLen*/,
308 BOOL * /*pEnabled*/);
309
310typedef struct sockaddr * sockaddrPtr;
311
312extern _X_EXPORT int InvalidHost(sockaddrPtr /*saddr*/, int /*len*/, ClientPtr client);
313
314extern _X_EXPORT int LocalClient(ClientPtr /* client */);
315
316extern _X_EXPORT int LocalClientCred(ClientPtr, int *, int *);
317
318#define LCC_UID_SET (1 << 0)
319#define LCC_GID_SET (1 << 1)
320#define LCC_PID_SET (1 << 2)
321#define LCC_ZID_SET (1 << 3)
322
323typedef struct {
324 int fieldsSet; /* Bit mask of fields set */
325 int euid; /* Effective uid */
326 int egid; /* Primary effective group id */
327 int nSuppGids; /* Number of supplementary group ids */
328 int *pSuppGids; /* Array of supplementary group ids */
329 int pid; /* Process id */
330 int zoneid; /* Only set on Solaris 10 & later */
331} LocalClientCredRec;
332
333extern _X_EXPORT int GetLocalClientCreds(ClientPtr, LocalClientCredRec **);
334extern _X_EXPORT void FreeLocalClientCreds(LocalClientCredRec *);
335
336extern _X_EXPORT int ChangeAccessControl(ClientPtr /*client*/, int /*fEnabled*/);
337
338extern _X_EXPORT int GetAccessControl(void);
339
340
341extern _X_EXPORT void AddLocalHosts(void);
342
343extern _X_EXPORT void ResetHosts(char *display);
344
345extern _X_EXPORT void EnableLocalHost(void);
346
347extern _X_EXPORT void DisableLocalHost(void);
348
349extern _X_EXPORT void AccessUsingXdmcp(void);
350
351extern _X_EXPORT void DefineSelf(int /*fd*/);
352
353#if XDMCP
354extern _X_EXPORT void AugmentSelf(pointer /*from*/, int /*len*/);
355
356extern _X_EXPORT void RegisterAuthorizations(void);
357#endif
358
359extern _X_EXPORT void InitAuthorization(char * /*filename*/);
360
361/* extern int LoadAuthorization(void); */
362
363extern _X_EXPORT int AuthorizationFromID (
364 XID id,
365 unsigned short *name_lenp,
366 char **namep,
367 unsigned short *data_lenp,
368 char **datap);
369
370extern _X_EXPORT XID CheckAuthorization(
371 unsigned int /*namelength*/,
372 char * /*name*/,
373 unsigned int /*datalength*/,
374 char * /*data*/,
375 ClientPtr /*client*/,
376 char ** /*reason*/
377);
378
379extern _X_EXPORT void ResetAuthorization(void);
380
381extern _X_EXPORT int RemoveAuthorization (
382 unsigned short name_length,
383 char *name,
384 unsigned short data_length,
385 char *data);
386
387extern _X_EXPORT int AddAuthorization(
388 unsigned int /*name_length*/,
389 char * /*name*/,
390 unsigned int /*data_length*/,
391 char * /*data*/);
392
393#ifdef XCSECURITY
394extern _X_EXPORT XID GenerateAuthorization(
395 unsigned int /* name_length */,
396 char * /* name */,
397 unsigned int /* data_length */,
398 char * /* data */,
399 unsigned int * /* data_length_return */,
400 char ** /* data_return */);
401#endif
402
403extern _X_EXPORT int ddxProcessArgument(int /*argc*/, char * /*argv*/ [], int /*i*/);
404
405extern _X_EXPORT void ddxUseMsg(void);
406
407/* int ReqLen(xReq *req, ClientPtr client)
408 * Given a pointer to a *complete* request, return its length in bytes.
409 * Note that if the request is a big request (as defined in the Big
410 * Requests extension), the macro lies by returning 4 less than the
411 * length that it actually occupies in the request buffer. This is so you
412 * can blindly compare the length with the various sz_<request> constants
413 * in Xproto.h without having to know/care about big requests.
414 */
415#define ReqLen(_pxReq, _client) \
416 ((_pxReq->length ? \
417 (_client->swapped ? lswaps(_pxReq->length) : _pxReq->length) \
418 : ((_client->swapped ? \
419 lswapl(((CARD32*)_pxReq)[1]) : ((CARD32*)_pxReq)[1])-1) \
420 ) << 2)
421
422/* otherReqTypePtr CastxReq(xReq *req, otherReqTypePtr)
423 * Cast the given request to one of type otherReqTypePtr to access
424 * fields beyond the length field.
425 */
426#define CastxReq(_pxReq, otherReqTypePtr) \
427 (_pxReq->length ? (otherReqTypePtr)_pxReq \
428 : (otherReqTypePtr)(((CARD32*)_pxReq)+1))
429
430/* stuff for ReplyCallback */
431extern _X_EXPORT CallbackListPtr ReplyCallback;
432typedef struct {
433 ClientPtr client;
434 const void *replyData;
435 unsigned long dataLenBytes;
436 unsigned long bytesRemaining;
437 Bool startOfReply;
438} ReplyInfoRec;
439
440/* stuff for FlushCallback */
441extern _X_EXPORT CallbackListPtr FlushCallback;
442
443extern _X_EXPORT void AbortDDX(void);
444extern _X_EXPORT void ddxGiveUp(void);
445extern _X_EXPORT int TimeSinceLastInputEvent(void);
446
447/* strcasecmp.c */
448#if NEED_STRCASECMP
449#define strcasecmp xstrcasecmp
450extern _X_EXPORT int xstrcasecmp(const char *s1, const char *s2);
451#endif
452
453#if NEED_STRNCASECMP
454#define strncasecmp xstrncasecmp
455extern _X_EXPORT int xstrncasecmp(const char *s1, const char *s2, size_t n);
456#endif
457
458#if NEED_STRCASESTR
459#define strcasestr xstrcasestr
460extern _X_EXPORT char *xstrcasestr(const char *s, const char *find);
461#endif
462
463#ifndef HAS_STRLCPY
464extern _X_EXPORT size_t strlcpy(char *dst, const char *src, size_t siz);
465extern _X_EXPORT size_t strlcat(char *dst, const char *src, size_t siz);
466#endif
467
468/* Logging. */
469typedef enum _LogParameter {
470 XLOG_FLUSH,
471 XLOG_SYNC,
472 XLOG_VERBOSITY,
473 XLOG_FILE_VERBOSITY
474} LogParameter;
475
476/* Flags for log messages. */
477typedef enum {
478 X_PROBED, /* Value was probed */
479 X_CONFIG, /* Value was given in the config file */
480 X_DEFAULT, /* Value is a default */
481 X_CMDLINE, /* Value was given on the command line */
482 X_NOTICE, /* Notice */
483 X_ERROR, /* Error message */
484 X_WARNING, /* Warning message */
485 X_INFO, /* Informational message */
486 X_NONE, /* No prefix */
487 X_NOT_IMPLEMENTED, /* Not implemented */
488 X_UNKNOWN = -1 /* unknown -- this must always be last */
489} MessageType;
490
491/* XXX Need to check which GCC versions have the format(printf) attribute. */
492#if defined(__GNUC__) && (__GNUC__ > 2)
493#define _printf_attribute(a,b) __attribute((format(__printf__,a,b)))
494#else
495#define _printf_attribute(a,b) /**/
496#endif
497
498extern _X_EXPORT const char *LogInit(const char *fname, const char *backup);
499extern _X_EXPORT void LogClose(void);
500extern _X_EXPORT Bool LogSetParameter(LogParameter param, int value);
501extern _X_EXPORT void LogVWrite(int verb, const char *f, va_list args);
502extern _X_EXPORT void LogWrite(int verb, const char *f, ...) _printf_attribute(2,3);
503extern _X_EXPORT void LogVMessageVerb(MessageType type, int verb, const char *format,
504 va_list args);
505extern _X_EXPORT void LogMessageVerb(MessageType type, int verb, const char *format,
506 ...) _printf_attribute(3,4);
507extern _X_EXPORT void LogMessage(MessageType type, const char *format, ...)
508 _printf_attribute(2,3);
509extern _X_EXPORT void FreeAuditTimer(void);
510extern _X_EXPORT void AuditF(const char *f, ...) _printf_attribute(1,2);
511extern _X_EXPORT void VAuditF(const char *f, va_list args);
512extern _X_EXPORT void FatalError(const char *f, ...) _printf_attribute(1,2)
513#if defined(__GNUC__) && (__GNUC__ > 2)
514__attribute((noreturn))
515#endif
516;
517
518#ifdef DEBUG
519#define DebugF ErrorF
520#else
521#define DebugF(...) /* */
522#endif
523
524extern _X_EXPORT void VErrorF(const char *f, va_list args);
525extern _X_EXPORT void ErrorF(const char *f, ...) _printf_attribute(1,2);
526extern _X_EXPORT void Error(char *str);
527extern _X_EXPORT void LogPrintMarkers(void);
528
529extern _X_EXPORT void xorg_backtrace(void);
530
531#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