VirtualBox

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

Last change on this file since 99743 was 43272, checked in by vboxsync, 12 years ago

Additions/x11: more original X server headers.

  • Property svn:eol-style set to native
File size: 16.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
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 DDXOSVERRORF
87extern _X_EXPORT void (*OsVendorVErrorFProc)(const char *, va_list args);
88#endif
89
90extern _X_EXPORT int WaitForSomething(
91 int* /*pClientsReady*/
92);
93
94extern _X_EXPORT int ReadRequestFromClient(ClientPtr /*client*/);
95
96extern _X_EXPORT Bool InsertFakeRequest(
97 ClientPtr /*client*/,
98 char* /*data*/,
99 int /*count*/);
100
101extern _X_EXPORT void ResetCurrentRequest(ClientPtr /*client*/);
102
103extern _X_EXPORT void FlushAllOutput(void);
104
105extern _X_EXPORT void FlushIfCriticalOutputPending(void);
106
107extern _X_EXPORT void SetCriticalOutputPending(void);
108
109extern _X_EXPORT int WriteToClient(ClientPtr /*who*/, int /*count*/, const void* /*buf*/);
110
111extern _X_EXPORT void ResetOsBuffers(void);
112
113extern _X_EXPORT void InitConnectionLimits(void);
114
115extern _X_EXPORT void NotifyParentProcess(void);
116
117extern _X_EXPORT void CreateWellKnownSockets(void);
118
119extern _X_EXPORT void ResetWellKnownSockets(void);
120
121extern _X_EXPORT void CloseWellKnownConnections(void);
122
123extern _X_EXPORT XID AuthorizationIDOfClient(ClientPtr /*client*/);
124
125extern _X_EXPORT char *ClientAuthorized(
126 ClientPtr /*client*/,
127 unsigned int /*proto_n*/,
128 char* /*auth_proto*/,
129 unsigned int /*string_n*/,
130 char* /*auth_string*/);
131
132extern _X_EXPORT Bool EstablishNewConnections(
133 ClientPtr /*clientUnused*/,
134 pointer /*closure*/);
135
136extern _X_EXPORT void CheckConnections(void);
137
138extern _X_EXPORT void CloseDownConnection(ClientPtr /*client*/);
139
140extern _X_EXPORT void AddGeneralSocket(int /*fd*/);
141
142extern _X_EXPORT void RemoveGeneralSocket(int /*fd*/);
143
144extern _X_EXPORT void AddEnabledDevice(int /*fd*/);
145
146extern _X_EXPORT void RemoveEnabledDevice(int /*fd*/);
147
148extern _X_EXPORT int OnlyListenToOneClient(ClientPtr /*client*/);
149
150extern _X_EXPORT void ListenToAllClients(void);
151
152extern _X_EXPORT void IgnoreClient(ClientPtr /*client*/);
153
154extern _X_EXPORT void AttendClient(ClientPtr /*client*/);
155
156extern _X_EXPORT void MakeClientGrabImpervious(ClientPtr /*client*/);
157
158extern _X_EXPORT void MakeClientGrabPervious(ClientPtr /*client*/);
159
160#ifdef XQUARTZ
161extern void ListenOnOpenFD(int /* fd */, int /* noxauth */);
162#endif
163
164extern _X_EXPORT CARD32 GetTimeInMillis(void);
165
166extern _X_EXPORT void AdjustWaitForDelay(
167 pointer /*waitTime*/,
168 unsigned long /*newdelay*/);
169
170typedef struct _OsTimerRec *OsTimerPtr;
171
172typedef CARD32 (*OsTimerCallback)(
173 OsTimerPtr /* timer */,
174 CARD32 /* time */,
175 pointer /* arg */);
176
177extern _X_EXPORT void TimerInit(void);
178
179extern _X_EXPORT Bool TimerForce(OsTimerPtr /* timer */);
180
181#define TimerAbsolute (1<<0)
182#define TimerForceOld (1<<1)
183
184extern _X_EXPORT OsTimerPtr TimerSet(
185 OsTimerPtr /* timer */,
186 int /* flags */,
187 CARD32 /* millis */,
188 OsTimerCallback /* func */,
189 pointer /* arg */);
190
191extern _X_EXPORT void TimerCheck(void);
192extern _X_EXPORT void TimerCancel(OsTimerPtr /* pTimer */);
193extern _X_EXPORT void TimerFree(OsTimerPtr /* pTimer */);
194
195extern _X_EXPORT void SetScreenSaverTimer(void);
196extern _X_EXPORT void FreeScreenSaverTimer(void);
197
198extern _X_EXPORT void AutoResetServer(int /*sig*/);
199
200extern _X_EXPORT void GiveUp(int /*sig*/);
201
202extern _X_EXPORT void UseMsg(void);
203
204extern _X_EXPORT void ProcessCommandLine(int /*argc*/, char* /*argv*/[]);
205
206extern _X_EXPORT int set_font_authorizations(
207 char ** /* authorizations */,
208 int * /*authlen */,
209 pointer /* client */);
210
211#ifndef _HAVE_XALLOC_DECLS
212#define _HAVE_XALLOC_DECLS
213extern _X_EXPORT pointer Xalloc(unsigned long /*amount*/);
214extern _X_EXPORT pointer Xcalloc(unsigned long /*amount*/);
215extern _X_EXPORT pointer Xrealloc(pointer /*ptr*/, unsigned long /*amount*/);
216extern _X_EXPORT void Xfree(pointer /*ptr*/);
217#endif
218
219extern _X_EXPORT pointer XNFalloc(unsigned long /*amount*/);
220extern _X_EXPORT pointer XNFcalloc(unsigned long /*amount*/);
221extern _X_EXPORT pointer XNFrealloc(pointer /*ptr*/, unsigned long /*amount*/);
222
223extern _X_EXPORT char *Xstrdup(const char *s);
224extern _X_EXPORT char *XNFstrdup(const char *s);
225extern _X_EXPORT char *Xprintf(const char *fmt, ...);
226extern _X_EXPORT char *Xvprintf(const char *fmt, va_list va);
227extern _X_EXPORT char *XNFprintf(const char *fmt, ...);
228extern _X_EXPORT char *XNFvprintf(const char *fmt, va_list va);
229
230typedef void (*OsSigHandlerPtr)(int /* sig */);
231typedef int (*OsSigWrapperPtr)(int /* sig */);
232
233extern _X_EXPORT OsSigHandlerPtr OsSignal(int /* sig */, OsSigHandlerPtr /* handler */);
234extern _X_EXPORT OsSigWrapperPtr OsRegisterSigWrapper(OsSigWrapperPtr newWrap);
235
236extern _X_EXPORT int auditTrailLevel;
237
238extern _X_EXPORT void LockServer(void);
239extern _X_EXPORT void UnlockServer(void);
240
241extern _X_EXPORT int OsLookupColor(
242 int /*screen*/,
243 char * /*name*/,
244 unsigned /*len*/,
245 unsigned short * /*pred*/,
246 unsigned short * /*pgreen*/,
247 unsigned short * /*pblue*/);
248
249extern _X_EXPORT void OsInit(void);
250
251extern _X_EXPORT void OsCleanup(Bool);
252
253extern _X_EXPORT void OsVendorFatalError(void);
254
255extern _X_EXPORT void OsVendorInit(void);
256
257extern _X_EXPORT void OsBlockSignals (void);
258
259extern _X_EXPORT void OsReleaseSignals (void);
260
261#if !defined(WIN32)
262extern _X_EXPORT int System(char *);
263extern _X_EXPORT pointer Popen(char *, char *);
264extern _X_EXPORT int Pclose(pointer);
265extern _X_EXPORT pointer Fopen(char *, char *);
266extern _X_EXPORT int Fclose(pointer);
267#else
268#define System(a) system(a)
269#define Popen(a,b) popen(a,b)
270#define Pclose(a) pclose(a)
271#define Fopen(a,b) fopen(a,b)
272#define Fclose(a) fclose(a)
273#endif
274
275extern _X_EXPORT void CheckUserParameters(int argc, char **argv, char **envp);
276extern _X_EXPORT void CheckUserAuthorization(void);
277
278extern _X_EXPORT int AddHost(
279 ClientPtr /*client*/,
280 int /*family*/,
281 unsigned /*length*/,
282 pointer /*pAddr*/);
283
284extern _X_EXPORT Bool ForEachHostInFamily (
285 int /*family*/,
286 Bool (* /*func*/ )(
287 unsigned char * /* addr */,
288 short /* len */,
289 pointer /* closure */),
290 pointer /*closure*/);
291
292extern _X_EXPORT int RemoveHost(
293 ClientPtr /*client*/,
294 int /*family*/,
295 unsigned /*length*/,
296 pointer /*pAddr*/);
297
298extern _X_EXPORT int GetHosts(
299 pointer * /*data*/,
300 int * /*pnHosts*/,
301 int * /*pLen*/,
302 BOOL * /*pEnabled*/);
303
304typedef struct sockaddr * sockaddrPtr;
305
306extern _X_EXPORT int InvalidHost(sockaddrPtr /*saddr*/, int /*len*/, ClientPtr client);
307
308extern _X_EXPORT int LocalClient(ClientPtr /* client */);
309
310extern _X_EXPORT int LocalClientCred(ClientPtr, int *, int *);
311
312#define LCC_UID_SET (1 << 0)
313#define LCC_GID_SET (1 << 1)
314#define LCC_PID_SET (1 << 2)
315#define LCC_ZID_SET (1 << 3)
316
317typedef struct {
318 int fieldsSet; /* Bit mask of fields set */
319 int euid; /* Effective uid */
320 int egid; /* Primary effective group id */
321 int nSuppGids; /* Number of supplementary group ids */
322 int *pSuppGids; /* Array of supplementary group ids */
323 int pid; /* Process id */
324 int zoneid; /* Only set on Solaris 10 & later */
325} LocalClientCredRec;
326
327extern _X_EXPORT int GetLocalClientCreds(ClientPtr, LocalClientCredRec **);
328extern _X_EXPORT void FreeLocalClientCreds(LocalClientCredRec *);
329
330extern _X_EXPORT int ChangeAccessControl(ClientPtr /*client*/, int /*fEnabled*/);
331
332extern _X_EXPORT int GetAccessControl(void);
333
334
335extern _X_EXPORT void AddLocalHosts(void);
336
337extern _X_EXPORT void ResetHosts(char *display);
338
339extern _X_EXPORT void EnableLocalHost(void);
340
341extern _X_EXPORT void DisableLocalHost(void);
342
343extern _X_EXPORT void AccessUsingXdmcp(void);
344
345extern _X_EXPORT void DefineSelf(int /*fd*/);
346
347#if XDMCP
348extern _X_EXPORT void AugmentSelf(pointer /*from*/, int /*len*/);
349
350extern _X_EXPORT void RegisterAuthorizations(void);
351#endif
352
353extern _X_EXPORT void InitAuthorization(char * /*filename*/);
354
355/* extern int LoadAuthorization(void); */
356
357extern _X_EXPORT int AuthorizationFromID (
358 XID id,
359 unsigned short *name_lenp,
360 char **namep,
361 unsigned short *data_lenp,
362 char **datap);
363
364extern _X_EXPORT XID CheckAuthorization(
365 unsigned int /*namelength*/,
366 char * /*name*/,
367 unsigned int /*datalength*/,
368 char * /*data*/,
369 ClientPtr /*client*/,
370 char ** /*reason*/
371);
372
373extern _X_EXPORT void ResetAuthorization(void);
374
375extern _X_EXPORT int RemoveAuthorization (
376 unsigned short name_length,
377 char *name,
378 unsigned short data_length,
379 char *data);
380
381extern _X_EXPORT int AddAuthorization(
382 unsigned int /*name_length*/,
383 char * /*name*/,
384 unsigned int /*data_length*/,
385 char * /*data*/);
386
387#ifdef XCSECURITY
388extern _X_EXPORT XID GenerateAuthorization(
389 unsigned int /* name_length */,
390 char * /* name */,
391 unsigned int /* data_length */,
392 char * /* data */,
393 unsigned int * /* data_length_return */,
394 char ** /* data_return */);
395#endif
396
397extern _X_EXPORT int ddxProcessArgument(int /*argc*/, char * /*argv*/ [], int /*i*/);
398
399extern _X_EXPORT void ddxUseMsg(void);
400
401/* int ReqLen(xReq *req, ClientPtr client)
402 * Given a pointer to a *complete* request, return its length in bytes.
403 * Note that if the request is a big request (as defined in the Big
404 * Requests extension), the macro lies by returning 4 less than the
405 * length that it actually occupies in the request buffer. This is so you
406 * can blindly compare the length with the various sz_<request> constants
407 * in Xproto.h without having to know/care about big requests.
408 */
409#define ReqLen(_pxReq, _client) \
410 ((_pxReq->length ? \
411 (_client->swapped ? lswaps(_pxReq->length) : _pxReq->length) \
412 : ((_client->swapped ? \
413 lswapl(((CARD32*)_pxReq)[1]) : ((CARD32*)_pxReq)[1])-1) \
414 ) << 2)
415
416/* otherReqTypePtr CastxReq(xReq *req, otherReqTypePtr)
417 * Cast the given request to one of type otherReqTypePtr to access
418 * fields beyond the length field.
419 */
420#define CastxReq(_pxReq, otherReqTypePtr) \
421 (_pxReq->length ? (otherReqTypePtr)_pxReq \
422 : (otherReqTypePtr)(((CARD32*)_pxReq)+1))
423
424/* stuff for ReplyCallback */
425extern _X_EXPORT CallbackListPtr ReplyCallback;
426typedef struct {
427 ClientPtr client;
428 const void *replyData;
429 unsigned long dataLenBytes;
430 unsigned long bytesRemaining;
431 Bool startOfReply;
432} ReplyInfoRec;
433
434/* stuff for FlushCallback */
435extern _X_EXPORT CallbackListPtr FlushCallback;
436
437extern _X_EXPORT void AbortDDX(void);
438extern _X_EXPORT void ddxGiveUp(void);
439extern _X_EXPORT int TimeSinceLastInputEvent(void);
440
441/* strcasecmp.c */
442#if NEED_STRCASECMP
443#define strcasecmp xstrcasecmp
444extern _X_EXPORT int xstrcasecmp(const char *s1, const char *s2);
445#endif
446
447#if NEED_STRNCASECMP
448#define strncasecmp xstrncasecmp
449extern _X_EXPORT int xstrncasecmp(const char *s1, const char *s2, size_t n);
450#endif
451
452#if NEED_STRCASESTR
453#define strcasestr xstrcasestr
454extern _X_EXPORT char *xstrcasestr(const char *s, const char *find);
455#endif
456
457#ifndef HAS_STRLCPY
458extern _X_EXPORT size_t strlcpy(char *dst, const char *src, size_t siz);
459extern _X_EXPORT size_t strlcat(char *dst, const char *src, size_t siz);
460#endif
461
462/* Logging. */
463typedef enum _LogParameter {
464 XLOG_FLUSH,
465 XLOG_SYNC,
466 XLOG_VERBOSITY,
467 XLOG_FILE_VERBOSITY
468} LogParameter;
469
470/* Flags for log messages. */
471typedef enum {
472 X_PROBED, /* Value was probed */
473 X_CONFIG, /* Value was given in the config file */
474 X_DEFAULT, /* Value is a default */
475 X_CMDLINE, /* Value was given on the command line */
476 X_NOTICE, /* Notice */
477 X_ERROR, /* Error message */
478 X_WARNING, /* Warning message */
479 X_INFO, /* Informational message */
480 X_NONE, /* No prefix */
481 X_NOT_IMPLEMENTED, /* Not implemented */
482 X_UNKNOWN = -1 /* unknown -- this must always be last */
483} MessageType;
484
485/* XXX Need to check which GCC versions have the format(printf) attribute. */
486#if defined(__GNUC__) && (__GNUC__ > 2)
487#define _printf_attribute(a,b) __attribute((format(__printf__,a,b)))
488#else
489#define _printf_attribute(a,b) /**/
490#endif
491
492extern _X_EXPORT const char *LogInit(const char *fname, const char *backup);
493extern _X_EXPORT void LogClose(void);
494extern _X_EXPORT Bool LogSetParameter(LogParameter param, int value);
495extern _X_EXPORT void LogVWrite(int verb, const char *f, va_list args);
496extern _X_EXPORT void LogWrite(int verb, const char *f, ...) _printf_attribute(2,3);
497extern _X_EXPORT void LogVMessageVerb(MessageType type, int verb, const char *format,
498 va_list args);
499extern _X_EXPORT void LogMessageVerb(MessageType type, int verb, const char *format,
500 ...) _printf_attribute(3,4);
501extern _X_EXPORT void LogMessage(MessageType type, const char *format, ...)
502 _printf_attribute(2,3);
503extern _X_EXPORT void FreeAuditTimer(void);
504extern _X_EXPORT void AuditF(const char *f, ...) _printf_attribute(1,2);
505extern _X_EXPORT void VAuditF(const char *f, va_list args);
506extern _X_EXPORT void FatalError(const char *f, ...) _printf_attribute(1,2)
507#if defined(__GNUC__) && (__GNUC__ > 2)
508__attribute((noreturn))
509#endif
510;
511
512#ifdef DEBUG
513#define DebugF ErrorF
514#else
515#define DebugF(...) /* */
516#endif
517
518extern _X_EXPORT void VErrorF(const char *f, va_list args);
519extern _X_EXPORT void ErrorF(const char *f, ...) _printf_attribute(1,2);
520extern _X_EXPORT void Error(char *str);
521extern _X_EXPORT void LogPrintMarkers(void);
522
523extern _X_EXPORT void xorg_backtrace(void);
524
525#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