VirtualBox

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

Last change on this file since 32915 was 17471, checked in by vboxsync, 16 years ago

export to OSE

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