VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/x11include/7.1/xorg/os.h@ 6684

Last change on this file since 6684 was 6202, checked in by vboxsync, 17 years ago

re-export x11

  • Property svn:eol-style set to native
File size: 15.2 KB
Line 
1/* $XFree86: xc/programs/Xserver/include/os.h,v 3.54 2003/10/30 21:21:06 herrb Exp $ */
2/***********************************************************
3
4Copyright 1987, 1998 The Open Group
5
6Permission to use, copy, modify, distribute, and sell this software and its
7documentation for any purpose is hereby granted without fee, provided that
8the above copyright notice appear in all copies and that both that
9copyright notice and this permission notice appear in supporting
10documentation.
11
12The above copyright notice and this permission notice shall be included in
13all copies or substantial portions of the Software.
14
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22Except as contained in this notice, the name of The Open Group shall not be
23used in advertising or otherwise to promote the sale, use or other dealings
24in this Software without prior written authorization from The Open Group.
25
26
27Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
28
29 All Rights Reserved
30
31Permission to use, copy, modify, and distribute this software and its
32documentation for any purpose and without fee is hereby granted,
33provided that the above copyright notice appear in all copies and that
34both that copyright notice and this permission notice appear in
35supporting documentation, and that the name of Digital not be
36used in advertising or publicity pertaining to distribution of the
37software without specific, written prior permission.
38
39DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
40ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
41DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
42ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
43WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
44ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
45SOFTWARE.
46
47******************************************************************/
48
49/* $Xorg: os.h,v 1.4 2001/02/09 02:05:15 xorgcvs Exp $ */
50
51#ifndef OS_H
52#define OS_H
53
54#include "misc.h"
55#define ALLOCATE_LOCAL_FALLBACK(_size) Xalloc((unsigned long)(_size))
56#define DEALLOCATE_LOCAL_FALLBACK(_ptr) Xfree((pointer)(_ptr))
57#include <X11/Xalloca.h>
58#include <stdarg.h>
59
60#define NullFID ((FID) 0)
61
62#define SCREEN_SAVER_ON 0
63#define SCREEN_SAVER_OFF 1
64#define SCREEN_SAVER_FORCER 2
65#define SCREEN_SAVER_CYCLE 3
66
67#ifndef MAX_REQUEST_SIZE
68#define MAX_REQUEST_SIZE 65535
69#endif
70#ifndef MAX_BIG_REQUEST_SIZE
71#define MAX_BIG_REQUEST_SIZE 4194303
72#endif
73
74typedef pointer FID;
75typedef struct _FontPathRec *FontPathPtr;
76typedef struct _NewClientRec *NewClientPtr;
77
78#ifndef xalloc
79#define xnfalloc(size) XNFalloc((unsigned long)(size))
80#define xnfcalloc(_num, _size) XNFcalloc((unsigned long)(_num)*(unsigned long)(_size))
81#define xnfrealloc(ptr, size) XNFrealloc((pointer)(ptr), (unsigned long)(size))
82
83#define xalloc(size) Xalloc((unsigned long)(size))
84#define xcalloc(_num, _size) Xcalloc((unsigned long)(_num)*(unsigned long)(_size))
85#define xrealloc(ptr, size) Xrealloc((pointer)(ptr), (unsigned long)(size))
86#define xfree(ptr) Xfree((pointer)(ptr))
87#define xstrdup(s) Xstrdup(s)
88#define xnfstrdup(s) XNFstrdup(s)
89#endif
90
91#ifndef IN_MODULE
92#ifdef __SCO__
93#include <stdio.h>
94#endif
95#include <string.h>
96#endif
97
98/* have to put $(SIGNAL_DEFINES) in DEFINES in Imakefile to get this right */
99#ifdef SIGNALRETURNSINT
100#define SIGVAL int
101#else
102#define SIGVAL void
103#endif
104
105extern Bool OsDelayInitColors;
106extern void (*OsVendorVErrorFProc)(const char *, va_list args);
107
108extern int WaitForSomething(
109 int* /*pClientsReady*/
110);
111
112#ifdef LBX
113#define ReadRequestFromClient(client) ((client)->readRequest(client))
114extern int StandardReadRequestFromClient(ClientPtr /*client*/);
115
116extern int ClientConnectionNumber(ClientPtr /*client*/);
117#else
118extern int ReadRequestFromClient(ClientPtr /*client*/);
119#endif /* LBX */
120
121extern Bool InsertFakeRequest(
122 ClientPtr /*client*/,
123 char* /*data*/,
124 int /*count*/);
125
126extern void ResetCurrentRequest(ClientPtr /*client*/);
127
128extern void FlushAllOutput(void);
129
130extern void FlushIfCriticalOutputPending(void);
131
132extern void SetCriticalOutputPending(void);
133
134extern int WriteToClient(ClientPtr /*who*/, int /*count*/, char* /*buf*/);
135
136extern void ResetOsBuffers(void);
137
138extern void InitConnectionLimits(void);
139
140extern void CreateWellKnownSockets(void);
141
142extern void ResetWellKnownSockets(void);
143
144extern void CloseWellKnownConnections(void);
145
146extern XID AuthorizationIDOfClient(ClientPtr /*client*/);
147
148extern char *ClientAuthorized(
149 ClientPtr /*client*/,
150 unsigned int /*proto_n*/,
151 char* /*auth_proto*/,
152 unsigned int /*string_n*/,
153 char* /*auth_string*/);
154
155extern Bool EstablishNewConnections(
156 ClientPtr /*clientUnused*/,
157 pointer /*closure*/);
158
159extern void CheckConnections(void);
160
161extern void CloseDownConnection(ClientPtr /*client*/);
162
163extern void AddEnabledDevice(int /*fd*/);
164
165extern void RemoveEnabledDevice(int /*fd*/);
166
167extern void OnlyListenToOneClient(ClientPtr /*client*/);
168
169extern void ListenToAllClients(void);
170
171extern void IgnoreClient(ClientPtr /*client*/);
172
173extern void AttendClient(ClientPtr /*client*/);
174
175extern void MakeClientGrabImpervious(ClientPtr /*client*/);
176
177extern void MakeClientGrabPervious(ClientPtr /*client*/);
178
179#ifdef LBX
180extern void CloseDownFileDescriptor(ClientPtr /* client */);
181#endif
182
183extern void AvailableClientInput(ClientPtr /* client */);
184
185extern CARD32 GetTimeInMillis(void);
186
187extern void AdjustWaitForDelay(
188 pointer /*waitTime*/,
189 unsigned long /*newdelay*/);
190
191typedef struct _OsTimerRec *OsTimerPtr;
192
193typedef CARD32 (*OsTimerCallback)(
194 OsTimerPtr /* timer */,
195 CARD32 /* time */,
196 pointer /* arg */);
197
198extern void TimerInit(void);
199
200extern Bool TimerForce(OsTimerPtr /* timer */);
201
202#define TimerAbsolute (1<<0)
203#define TimerForceOld (1<<1)
204
205extern OsTimerPtr TimerSet(
206 OsTimerPtr /* timer */,
207 int /* flags */,
208 CARD32 /* millis */,
209 OsTimerCallback /* func */,
210 pointer /* arg */);
211
212extern void TimerCheck(void);
213extern void TimerCancel(OsTimerPtr /* pTimer */);
214extern void TimerFree(OsTimerPtr /* pTimer */);
215
216extern void SetScreenSaverTimer(void);
217extern void FreeScreenSaverTimer(void);
218
219extern SIGVAL AutoResetServer(int /*sig*/);
220
221extern SIGVAL GiveUp(int /*sig*/);
222
223extern void UseMsg(void);
224
225extern void InitGlobals(void);
226
227extern void ProcessCommandLine(int /*argc*/, char* /*argv*/[]);
228
229extern int set_font_authorizations(
230 char ** /* authorizations */,
231 int * /*authlen */,
232 pointer /* client */);
233
234#ifndef _HAVE_XALLOC_DECLS
235#define _HAVE_XALLOC_DECLS
236extern pointer Xalloc(unsigned long /*amount*/);
237extern pointer Xcalloc(unsigned long /*amount*/);
238extern pointer Xrealloc(pointer /*ptr*/, unsigned long /*amount*/);
239extern void Xfree(pointer /*ptr*/);
240#endif
241
242extern pointer XNFalloc(unsigned long /*amount*/);
243extern pointer XNFcalloc(unsigned long /*amount*/);
244extern pointer XNFrealloc(pointer /*ptr*/, unsigned long /*amount*/);
245
246extern void OsInitAllocator(void);
247
248extern char *Xstrdup(const char *s);
249extern char *XNFstrdup(const char *s);
250extern char *Xprintf(const char *fmt, ...);
251extern char *Xvprintf(const char *fmt, va_list va);
252extern char *XNFprintf(const char *fmt, ...);
253extern char *XNFvprintf(const char *fmt, va_list va);
254
255typedef SIGVAL (*OsSigHandlerPtr)(int /* sig */);
256
257extern OsSigHandlerPtr OsSignal(int /* sig */, OsSigHandlerPtr /* handler */);
258
259extern int auditTrailLevel;
260
261#ifdef SERVER_LOCK
262extern void LockServer(void);
263extern void UnlockServer(void);
264#endif
265
266extern int OsLookupColor(
267 int /*screen*/,
268 char * /*name*/,
269 unsigned /*len*/,
270 unsigned short * /*pred*/,
271 unsigned short * /*pgreen*/,
272 unsigned short * /*pblue*/);
273
274extern void OsInit(void);
275
276extern void OsCleanup(Bool);
277
278extern void OsVendorFatalError(void);
279
280extern void OsVendorInit(void);
281
282extern int OsInitColors(void);
283
284void OsBlockSignals (void);
285
286void OsReleaseSignals (void);
287
288#if !defined(WIN32) && !defined(__UNIXOS2__)
289extern int System(char *);
290extern pointer Popen(char *, char *);
291extern int Pclose(pointer);
292extern pointer Fopen(char *, char *);
293extern int Fclose(pointer);
294#else
295#define System(a) system(a)
296#define Popen(a,b) popen(a,b)
297#define Pclose(a) pclose(a)
298#define Fopen(a,b) fopen(a,b)
299#define Fclose(a) fclose(a)
300#endif
301
302extern void CheckUserParameters(int argc, char **argv, char **envp);
303extern void CheckUserAuthorization(void);
304
305extern int AddHost(
306 ClientPtr /*client*/,
307 int /*family*/,
308 unsigned /*length*/,
309 pointer /*pAddr*/);
310
311extern Bool ForEachHostInFamily (
312 int /*family*/,
313 Bool (* /*func*/ )(
314 unsigned char * /* addr */,
315 short /* len */,
316 pointer /* closure */),
317 pointer /*closure*/);
318
319extern int RemoveHost(
320 ClientPtr /*client*/,
321 int /*family*/,
322 unsigned /*length*/,
323 pointer /*pAddr*/);
324
325extern int GetHosts(
326 pointer * /*data*/,
327 int * /*pnHosts*/,
328 int * /*pLen*/,
329 BOOL * /*pEnabled*/);
330
331typedef struct sockaddr * sockaddrPtr;
332
333extern int InvalidHost(sockaddrPtr /*saddr*/, int /*len*/, ClientPtr client);
334
335extern int LocalClient(ClientPtr /* client */);
336
337extern int LocalClientCred(ClientPtr, int *, int *);
338
339extern int ChangeAccessControl(ClientPtr /*client*/, int /*fEnabled*/);
340
341extern int GetAccessControl(void);
342
343
344extern void AddLocalHosts(void);
345
346extern void ResetHosts(char *display);
347
348extern void EnableLocalHost(void);
349
350extern void DisableLocalHost(void);
351
352extern void AccessUsingXdmcp(void);
353
354extern void DefineSelf(int /*fd*/);
355
356extern void AugmentSelf(pointer /*from*/, int /*len*/);
357
358extern void InitAuthorization(char * /*filename*/);
359
360/* extern int LoadAuthorization(void); */
361
362extern void RegisterAuthorizations(void);
363
364extern XID AuthorizationToID (
365 unsigned short name_length,
366 char *name,
367 unsigned short data_length,
368 char *data);
369
370extern int AuthorizationFromID (
371 XID id,
372 unsigned short *name_lenp,
373 char **namep,
374 unsigned short *data_lenp,
375 char **datap);
376
377extern XID CheckAuthorization(
378 unsigned int /*namelength*/,
379 char * /*name*/,
380 unsigned int /*datalength*/,
381 char * /*data*/,
382 ClientPtr /*client*/,
383 char ** /*reason*/
384);
385
386extern void ResetAuthorization(void);
387
388extern int RemoveAuthorization (
389 unsigned short name_length,
390 char *name,
391 unsigned short data_length,
392 char *data);
393
394extern int AddAuthorization(
395 unsigned int /*name_length*/,
396 char * /*name*/,
397 unsigned int /*data_length*/,
398 char * /*data*/);
399
400extern XID GenerateAuthorization(
401 unsigned int /* name_length */,
402 char * /* name */,
403 unsigned int /* data_length */,
404 char * /* data */,
405 unsigned int * /* data_length_return */,
406 char ** /* data_return */);
407
408#ifdef COMMANDLINE_CHALLENGED_OPERATING_SYSTEMS
409extern void ExpandCommandLine(int * /*pargc*/, char *** /*pargv*/);
410#endif
411
412extern void ddxInitGlobals(void);
413
414extern int ddxProcessArgument(int /*argc*/, char * /*argv*/ [], int /*i*/);
415
416extern void ddxUseMsg(void);
417
418/*
419 * idiom processing stuff
420 */
421
422extern xReqPtr PeekNextRequest(xReqPtr req, ClientPtr client, Bool readmore);
423
424extern void SkipRequests(xReqPtr req, ClientPtr client, int numskipped);
425
426/* int ReqLen(xReq *req, ClientPtr client)
427 * Given a pointer to a *complete* request, return its length in bytes.
428 * Note that if the request is a big request (as defined in the Big
429 * Requests extension), the macro lies by returning 4 less than the
430 * length that it actually occupies in the request buffer. This is so you
431 * can blindly compare the length with the various sz_<request> constants
432 * in Xproto.h without having to know/care about big requests.
433 */
434#define ReqLen(_pxReq, _client) \
435 ((_pxReq->length ? \
436 (_client->swapped ? lswaps(_pxReq->length) : _pxReq->length) \
437 : ((_client->swapped ? \
438 lswapl(((CARD32*)_pxReq)[1]) : ((CARD32*)_pxReq)[1])-1) \
439 ) << 2)
440
441/* otherReqTypePtr CastxReq(xReq *req, otherReqTypePtr)
442 * Cast the given request to one of type otherReqTypePtr to access
443 * fields beyond the length field.
444 */
445#define CastxReq(_pxReq, otherReqTypePtr) \
446 (_pxReq->length ? (otherReqTypePtr)_pxReq \
447 : (otherReqTypePtr)(((CARD32*)_pxReq)+1))
448
449/* stuff for SkippedRequestsCallback */
450extern CallbackListPtr SkippedRequestsCallback;
451typedef struct {
452 xReqPtr req;
453 ClientPtr client;
454 int numskipped;
455} SkippedRequestInfoRec;
456
457/* stuff for ReplyCallback */
458extern CallbackListPtr ReplyCallback;
459typedef struct {
460 ClientPtr client;
461 pointer replyData;
462 unsigned long dataLenBytes;
463 unsigned long bytesRemaining;
464 Bool startOfReply;
465} ReplyInfoRec;
466
467/* stuff for FlushCallback */
468extern CallbackListPtr FlushCallback;
469
470extern void AbortDDX(void);
471extern void ddxGiveUp(void);
472extern int TimeSinceLastInputEvent(void);
473
474/* Logging. */
475typedef enum _LogParameter {
476 XLOG_FLUSH,
477 XLOG_SYNC,
478 XLOG_VERBOSITY,
479 XLOG_FILE_VERBOSITY
480} LogParameter;
481
482/* Flags for log messages. */
483typedef enum {
484 X_PROBED, /* Value was probed */
485 X_CONFIG, /* Value was given in the config file */
486 X_DEFAULT, /* Value is a default */
487 X_CMDLINE, /* Value was given on the command line */
488 X_NOTICE, /* Notice */
489 X_ERROR, /* Error message */
490 X_WARNING, /* Warning message */
491 X_INFO, /* Informational message */
492 X_NONE, /* No prefix */
493 X_NOT_IMPLEMENTED, /* Not implemented */
494 X_UNKNOWN = -1 /* unknown -- this must always be last */
495} MessageType;
496
497/* XXX Need to check which GCC versions have the format(printf) attribute. */
498#if defined(__GNUC__) && \
499 ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ > 4)))
500#define _printf_attribute(a,b) __attribute((format(__printf__,a,b)))
501#else
502#define _printf_attribute(a,b) /**/
503#endif
504
505extern const char *LogInit(const char *fname, const char *backup);
506extern void LogClose(void);
507extern Bool LogSetParameter(LogParameter param, int value);
508extern void LogVWrite(int verb, const char *f, va_list args);
509extern void LogWrite(int verb, const char *f, ...) _printf_attribute(2,3);
510extern void LogVMessageVerb(MessageType type, int verb, const char *format,
511 va_list args);
512extern void LogMessageVerb(MessageType type, int verb, const char *format,
513 ...) _printf_attribute(3,4);
514extern void LogMessage(MessageType type, const char *format, ...)
515 _printf_attribute(2,3);
516extern void FreeAuditTimer(void);
517extern void AuditF(const char *f, ...) _printf_attribute(1,2);
518extern void VAuditF(const char *f, va_list args);
519extern void FatalError(const char *f, ...) _printf_attribute(1,2)
520#if defined(__GNUC__) && \
521 ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ > 4)))
522__attribute((noreturn))
523#endif
524;
525
526extern void VErrorF(const char *f, va_list args);
527extern void ErrorF(const char *f, ...) _printf_attribute(1,2);
528extern void Error(char *str);
529extern void LogPrintMarkers(void);
530
531#if defined(NEED_SNPRINTF) && !defined(IN_MODULE)
532extern int snprintf(char *str, size_t size, const char *format, ...)
533 _printf_attribute(3,4);
534extern int vsnprintf(char *str, size_t size, const char *format, va_list ap);
535#endif
536
537#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