VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/x11include/1.3/xorg/os.h@ 17240

Last change on this file since 17240 was 17236, checked in by vboxsync, 16 years ago

Additions/x11/x11include: blast! Reverted r43555 and r43556

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