1 | /***********************************************************
|
---|
2 |
|
---|
3 | Copyright 1987, 1998 The Open Group
|
---|
4 |
|
---|
5 | Permission to use, copy, modify, distribute, and sell this software and its
|
---|
6 | documentation for any purpose is hereby granted without fee, provided that
|
---|
7 | the above copyright notice appear in all copies and that both that
|
---|
8 | copyright notice and this permission notice appear in supporting
|
---|
9 | documentation.
|
---|
10 |
|
---|
11 | The above copyright notice and this permission notice shall be included in
|
---|
12 | all copies or substantial portions of the Software.
|
---|
13 |
|
---|
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
---|
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
---|
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
---|
17 | OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
---|
18 | AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
---|
19 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
---|
20 |
|
---|
21 | Except as contained in this notice, the name of The Open Group shall not be
|
---|
22 | used in advertising or otherwise to promote the sale, use or other dealings
|
---|
23 | in this Software without prior written authorization from The Open Group.
|
---|
24 |
|
---|
25 |
|
---|
26 | Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
|
---|
27 |
|
---|
28 | All Rights Reserved
|
---|
29 |
|
---|
30 | Permission to use, copy, modify, and distribute this software and its
|
---|
31 | documentation for any purpose and without fee is hereby granted,
|
---|
32 | provided that the above copyright notice appear in all copies and that
|
---|
33 | both that copyright notice and this permission notice appear in
|
---|
34 | supporting documentation, and that the name of Digital not be
|
---|
35 | used in advertising or publicity pertaining to distribution of the
|
---|
36 | software without specific, written prior permission.
|
---|
37 |
|
---|
38 | DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
---|
39 | ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
---|
40 | DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
---|
41 | ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
---|
42 | WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
---|
43 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
---|
44 | SOFTWARE.
|
---|
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 |
|
---|
67 | typedef struct _FontPathRec *FontPathPtr;
|
---|
68 | typedef 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
|
---|
87 | extern void ddxBeforeReset (void);
|
---|
88 | #endif
|
---|
89 |
|
---|
90 | #ifdef DDXOSVERRORF
|
---|
91 | extern _X_EXPORT void (*OsVendorVErrorFProc)(const char *, va_list args);
|
---|
92 | #endif
|
---|
93 |
|
---|
94 | extern _X_EXPORT int WaitForSomething(
|
---|
95 | int* /*pClientsReady*/
|
---|
96 | );
|
---|
97 |
|
---|
98 | extern _X_EXPORT int ReadRequestFromClient(ClientPtr /*client*/);
|
---|
99 |
|
---|
100 | extern _X_EXPORT Bool InsertFakeRequest(
|
---|
101 | ClientPtr /*client*/,
|
---|
102 | char* /*data*/,
|
---|
103 | int /*count*/);
|
---|
104 |
|
---|
105 | extern _X_EXPORT void ResetCurrentRequest(ClientPtr /*client*/);
|
---|
106 |
|
---|
107 | extern _X_EXPORT void FlushAllOutput(void);
|
---|
108 |
|
---|
109 | extern _X_EXPORT void FlushIfCriticalOutputPending(void);
|
---|
110 |
|
---|
111 | extern _X_EXPORT void SetCriticalOutputPending(void);
|
---|
112 |
|
---|
113 | extern _X_EXPORT int WriteToClient(ClientPtr /*who*/, int /*count*/, const void* /*buf*/);
|
---|
114 |
|
---|
115 | extern _X_EXPORT void ResetOsBuffers(void);
|
---|
116 |
|
---|
117 | extern _X_EXPORT void InitConnectionLimits(void);
|
---|
118 |
|
---|
119 | extern _X_EXPORT void NotifyParentProcess(void);
|
---|
120 |
|
---|
121 | extern _X_EXPORT void CreateWellKnownSockets(void);
|
---|
122 |
|
---|
123 | extern _X_EXPORT void ResetWellKnownSockets(void);
|
---|
124 |
|
---|
125 | extern _X_EXPORT void CloseWellKnownConnections(void);
|
---|
126 |
|
---|
127 | extern _X_EXPORT XID AuthorizationIDOfClient(ClientPtr /*client*/);
|
---|
128 |
|
---|
129 | extern _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 |
|
---|
136 | extern _X_EXPORT Bool EstablishNewConnections(
|
---|
137 | ClientPtr /*clientUnused*/,
|
---|
138 | pointer /*closure*/);
|
---|
139 |
|
---|
140 | extern _X_EXPORT void CheckConnections(void);
|
---|
141 |
|
---|
142 | extern _X_EXPORT void CloseDownConnection(ClientPtr /*client*/);
|
---|
143 |
|
---|
144 | extern _X_EXPORT void AddGeneralSocket(int /*fd*/);
|
---|
145 |
|
---|
146 | extern _X_EXPORT void RemoveGeneralSocket(int /*fd*/);
|
---|
147 |
|
---|
148 | extern _X_EXPORT void AddEnabledDevice(int /*fd*/);
|
---|
149 |
|
---|
150 | extern _X_EXPORT void RemoveEnabledDevice(int /*fd*/);
|
---|
151 |
|
---|
152 | extern _X_EXPORT int OnlyListenToOneClient(ClientPtr /*client*/);
|
---|
153 |
|
---|
154 | extern _X_EXPORT void ListenToAllClients(void);
|
---|
155 |
|
---|
156 | extern _X_EXPORT void IgnoreClient(ClientPtr /*client*/);
|
---|
157 |
|
---|
158 | extern _X_EXPORT void AttendClient(ClientPtr /*client*/);
|
---|
159 |
|
---|
160 | extern _X_EXPORT void MakeClientGrabImpervious(ClientPtr /*client*/);
|
---|
161 |
|
---|
162 | extern _X_EXPORT void MakeClientGrabPervious(ClientPtr /*client*/);
|
---|
163 |
|
---|
164 | #ifdef XQUARTZ
|
---|
165 | extern void ListenOnOpenFD(int /* fd */, int /* noxauth */);
|
---|
166 | #endif
|
---|
167 |
|
---|
168 | extern _X_EXPORT CARD32 GetTimeInMillis(void);
|
---|
169 |
|
---|
170 | extern _X_EXPORT void AdjustWaitForDelay(
|
---|
171 | pointer /*waitTime*/,
|
---|
172 | unsigned long /*newdelay*/);
|
---|
173 |
|
---|
174 | typedef struct _OsTimerRec *OsTimerPtr;
|
---|
175 |
|
---|
176 | typedef CARD32 (*OsTimerCallback)(
|
---|
177 | OsTimerPtr /* timer */,
|
---|
178 | CARD32 /* time */,
|
---|
179 | pointer /* arg */);
|
---|
180 |
|
---|
181 | extern _X_EXPORT void TimerInit(void);
|
---|
182 |
|
---|
183 | extern _X_EXPORT Bool TimerForce(OsTimerPtr /* timer */);
|
---|
184 |
|
---|
185 | #define TimerAbsolute (1<<0)
|
---|
186 | #define TimerForceOld (1<<1)
|
---|
187 |
|
---|
188 | extern _X_EXPORT OsTimerPtr TimerSet(
|
---|
189 | OsTimerPtr /* timer */,
|
---|
190 | int /* flags */,
|
---|
191 | CARD32 /* millis */,
|
---|
192 | OsTimerCallback /* func */,
|
---|
193 | pointer /* arg */);
|
---|
194 |
|
---|
195 | extern _X_EXPORT void TimerCheck(void);
|
---|
196 | extern _X_EXPORT void TimerCancel(OsTimerPtr /* pTimer */);
|
---|
197 | extern _X_EXPORT void TimerFree(OsTimerPtr /* pTimer */);
|
---|
198 |
|
---|
199 | extern _X_EXPORT void SetScreenSaverTimer(void);
|
---|
200 | extern _X_EXPORT void FreeScreenSaverTimer(void);
|
---|
201 |
|
---|
202 | extern _X_EXPORT void AutoResetServer(int /*sig*/);
|
---|
203 |
|
---|
204 | extern _X_EXPORT void GiveUp(int /*sig*/);
|
---|
205 |
|
---|
206 | extern _X_EXPORT void UseMsg(void);
|
---|
207 |
|
---|
208 | extern _X_EXPORT void ProcessCommandLine(int /*argc*/, char* /*argv*/[]);
|
---|
209 |
|
---|
210 | extern _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
|
---|
217 |
|
---|
218 | /*
|
---|
219 | * Use malloc(3) instead.
|
---|
220 | */
|
---|
221 | extern _X_EXPORT void *Xalloc(unsigned long /*amount*/) _X_DEPRECATED;
|
---|
222 | /*
|
---|
223 | * Use calloc(3) instead
|
---|
224 | */
|
---|
225 | extern _X_EXPORT void *Xcalloc(unsigned long /*amount*/) _X_DEPRECATED;
|
---|
226 | /*
|
---|
227 | * Use realloc(3) instead
|
---|
228 | */
|
---|
229 | extern _X_EXPORT void *Xrealloc(void * /*ptr*/, unsigned long /*amount*/)
|
---|
230 | _X_DEPRECATED;
|
---|
231 | /*
|
---|
232 | * Use free(3) instead
|
---|
233 | */
|
---|
234 | extern _X_EXPORT void Xfree(void * /*ptr*/) _X_DEPRECATED;
|
---|
235 |
|
---|
236 | #endif
|
---|
237 |
|
---|
238 | /*
|
---|
239 | * This function malloc(3)s buffer, terminating the server if there is not
|
---|
240 | * enough memory.
|
---|
241 | */
|
---|
242 | extern _X_EXPORT void *XNFalloc(unsigned long /*amount*/);
|
---|
243 | /*
|
---|
244 | * This function calloc(3)s buffer, terminating the server if there is not
|
---|
245 | * enough memory.
|
---|
246 | */
|
---|
247 | extern _X_EXPORT void *XNFcalloc(unsigned long /*amount*/);
|
---|
248 | /*
|
---|
249 | * This function realloc(3)s passed buffer, terminating the server if there is
|
---|
250 | * not enough memory.
|
---|
251 | */
|
---|
252 | extern _X_EXPORT void *XNFrealloc(void * /*ptr*/, unsigned long /*amount*/);
|
---|
253 |
|
---|
254 | /*
|
---|
255 | * This function strdup(3)s passed string. The only difference from the library
|
---|
256 | * function that it is safe to pass NULL, as NULL will be returned.
|
---|
257 | */
|
---|
258 | extern _X_EXPORT char *Xstrdup(const char *s);
|
---|
259 |
|
---|
260 | /*
|
---|
261 | * This function strdup(3)s passed string, terminating the server if there is
|
---|
262 | * not enough memory. If NULL is passed to this function, NULL is returned.
|
---|
263 | */
|
---|
264 | extern _X_EXPORT char *XNFstrdup(const char *s);
|
---|
265 |
|
---|
266 | extern _X_EXPORT char *Xprintf(const char *fmt, ...) _X_ATTRIBUTE_PRINTF(1,2);
|
---|
267 | extern _X_EXPORT char *Xvprintf(const char *fmt, va_list va);
|
---|
268 | extern _X_EXPORT char *XNFprintf(const char *fmt, ...) _X_ATTRIBUTE_PRINTF(1,2);
|
---|
269 | extern _X_EXPORT char *XNFvprintf(const char *fmt, va_list va);
|
---|
270 |
|
---|
271 | typedef void (*OsSigHandlerPtr)(int /* sig */);
|
---|
272 | typedef int (*OsSigWrapperPtr)(int /* sig */);
|
---|
273 |
|
---|
274 | extern _X_EXPORT OsSigHandlerPtr OsSignal(int /* sig */, OsSigHandlerPtr /* handler */);
|
---|
275 | extern _X_EXPORT OsSigWrapperPtr OsRegisterSigWrapper(OsSigWrapperPtr newWrap);
|
---|
276 |
|
---|
277 | extern _X_EXPORT int auditTrailLevel;
|
---|
278 |
|
---|
279 | extern _X_EXPORT void LockServer(void);
|
---|
280 | extern _X_EXPORT void UnlockServer(void);
|
---|
281 |
|
---|
282 | extern _X_EXPORT int OsLookupColor(
|
---|
283 | int /*screen*/,
|
---|
284 | char * /*name*/,
|
---|
285 | unsigned /*len*/,
|
---|
286 | unsigned short * /*pred*/,
|
---|
287 | unsigned short * /*pgreen*/,
|
---|
288 | unsigned short * /*pblue*/);
|
---|
289 |
|
---|
290 | extern _X_EXPORT void OsInit(void);
|
---|
291 |
|
---|
292 | extern _X_EXPORT void OsCleanup(Bool);
|
---|
293 |
|
---|
294 | extern _X_EXPORT void OsVendorFatalError(void);
|
---|
295 |
|
---|
296 | extern _X_EXPORT void OsVendorInit(void);
|
---|
297 |
|
---|
298 | extern _X_EXPORT void OsBlockSignals (void);
|
---|
299 |
|
---|
300 | extern _X_EXPORT void OsReleaseSignals (void);
|
---|
301 |
|
---|
302 | extern _X_EXPORT void OsAbort (void) _X_NORETURN;
|
---|
303 |
|
---|
304 | #if !defined(WIN32)
|
---|
305 | extern _X_EXPORT int System(char *);
|
---|
306 | extern _X_EXPORT pointer Popen(char *, char *);
|
---|
307 | extern _X_EXPORT int Pclose(pointer);
|
---|
308 | extern _X_EXPORT pointer Fopen(char *, char *);
|
---|
309 | extern _X_EXPORT int Fclose(pointer);
|
---|
310 | #else
|
---|
311 | #define System(a) system(a)
|
---|
312 | #define Popen(a,b) popen(a,b)
|
---|
313 | #define Pclose(a) pclose(a)
|
---|
314 | #define Fopen(a,b) fopen(a,b)
|
---|
315 | #define Fclose(a) fclose(a)
|
---|
316 | #endif
|
---|
317 |
|
---|
318 | extern _X_EXPORT void CheckUserParameters(int argc, char **argv, char **envp);
|
---|
319 | extern _X_EXPORT void CheckUserAuthorization(void);
|
---|
320 |
|
---|
321 | extern _X_EXPORT int AddHost(
|
---|
322 | ClientPtr /*client*/,
|
---|
323 | int /*family*/,
|
---|
324 | unsigned /*length*/,
|
---|
325 | const void */*pAddr*/);
|
---|
326 |
|
---|
327 | extern _X_EXPORT Bool ForEachHostInFamily (
|
---|
328 | int /*family*/,
|
---|
329 | Bool (* /*func*/ )(
|
---|
330 | unsigned char * /* addr */,
|
---|
331 | short /* len */,
|
---|
332 | pointer /* closure */),
|
---|
333 | pointer /*closure*/);
|
---|
334 |
|
---|
335 | extern _X_EXPORT int RemoveHost(
|
---|
336 | ClientPtr /*client*/,
|
---|
337 | int /*family*/,
|
---|
338 | unsigned /*length*/,
|
---|
339 | pointer /*pAddr*/);
|
---|
340 |
|
---|
341 | extern _X_EXPORT int GetHosts(
|
---|
342 | pointer * /*data*/,
|
---|
343 | int * /*pnHosts*/,
|
---|
344 | int * /*pLen*/,
|
---|
345 | BOOL * /*pEnabled*/);
|
---|
346 |
|
---|
347 | typedef struct sockaddr * sockaddrPtr;
|
---|
348 |
|
---|
349 | extern _X_EXPORT int InvalidHost(sockaddrPtr /*saddr*/, int /*len*/, ClientPtr client);
|
---|
350 |
|
---|
351 | extern _X_EXPORT int LocalClient(ClientPtr /* client */);
|
---|
352 |
|
---|
353 | extern _X_EXPORT int LocalClientCred(ClientPtr, int *, int *);
|
---|
354 |
|
---|
355 | #define LCC_UID_SET (1 << 0)
|
---|
356 | #define LCC_GID_SET (1 << 1)
|
---|
357 | #define LCC_PID_SET (1 << 2)
|
---|
358 | #define LCC_ZID_SET (1 << 3)
|
---|
359 |
|
---|
360 | typedef struct {
|
---|
361 | int fieldsSet; /* Bit mask of fields set */
|
---|
362 | int euid; /* Effective uid */
|
---|
363 | int egid; /* Primary effective group id */
|
---|
364 | int nSuppGids; /* Number of supplementary group ids */
|
---|
365 | int *pSuppGids; /* Array of supplementary group ids */
|
---|
366 | int pid; /* Process id */
|
---|
367 | int zoneid; /* Only set on Solaris 10 & later */
|
---|
368 | } LocalClientCredRec;
|
---|
369 |
|
---|
370 | extern _X_EXPORT int GetLocalClientCreds(ClientPtr, LocalClientCredRec **);
|
---|
371 | extern _X_EXPORT void FreeLocalClientCreds(LocalClientCredRec *);
|
---|
372 |
|
---|
373 | extern _X_EXPORT int ChangeAccessControl(ClientPtr /*client*/, int /*fEnabled*/);
|
---|
374 |
|
---|
375 | extern _X_EXPORT int GetAccessControl(void);
|
---|
376 |
|
---|
377 |
|
---|
378 | extern _X_EXPORT void AddLocalHosts(void);
|
---|
379 |
|
---|
380 | extern _X_EXPORT void ResetHosts(char *display);
|
---|
381 |
|
---|
382 | extern _X_EXPORT void EnableLocalHost(void);
|
---|
383 |
|
---|
384 | extern _X_EXPORT void DisableLocalHost(void);
|
---|
385 |
|
---|
386 | extern _X_EXPORT void AccessUsingXdmcp(void);
|
---|
387 |
|
---|
388 | extern _X_EXPORT void DefineSelf(int /*fd*/);
|
---|
389 |
|
---|
390 | #if XDMCP
|
---|
391 | extern _X_EXPORT void AugmentSelf(pointer /*from*/, int /*len*/);
|
---|
392 |
|
---|
393 | extern _X_EXPORT void RegisterAuthorizations(void);
|
---|
394 | #endif
|
---|
395 |
|
---|
396 | extern _X_EXPORT void InitAuthorization(char * /*filename*/);
|
---|
397 |
|
---|
398 | /* extern int LoadAuthorization(void); */
|
---|
399 |
|
---|
400 | extern _X_EXPORT int AuthorizationFromID (
|
---|
401 | XID id,
|
---|
402 | unsigned short *name_lenp,
|
---|
403 | char **namep,
|
---|
404 | unsigned short *data_lenp,
|
---|
405 | char **datap);
|
---|
406 |
|
---|
407 | extern _X_EXPORT XID CheckAuthorization(
|
---|
408 | unsigned int /*namelength*/,
|
---|
409 | const char * /*name*/,
|
---|
410 | unsigned int /*datalength*/,
|
---|
411 | const char * /*data*/,
|
---|
412 | ClientPtr /*client*/,
|
---|
413 | char ** /*reason*/
|
---|
414 | );
|
---|
415 |
|
---|
416 | extern _X_EXPORT void ResetAuthorization(void);
|
---|
417 |
|
---|
418 | extern _X_EXPORT int RemoveAuthorization (
|
---|
419 | unsigned short name_length,
|
---|
420 | const char *name,
|
---|
421 | unsigned short data_length,
|
---|
422 | const char *data);
|
---|
423 |
|
---|
424 | extern _X_EXPORT int AddAuthorization(
|
---|
425 | unsigned int /*name_length*/,
|
---|
426 | const char * /*name*/,
|
---|
427 | unsigned int /*data_length*/,
|
---|
428 | char * /*data*/);
|
---|
429 |
|
---|
430 | #ifdef XCSECURITY
|
---|
431 | extern _X_EXPORT XID GenerateAuthorization(
|
---|
432 | unsigned int /* name_length */,
|
---|
433 | const char * /* name */,
|
---|
434 | unsigned int /* data_length */,
|
---|
435 | const char * /* data */,
|
---|
436 | unsigned int * /* data_length_return */,
|
---|
437 | char ** /* data_return */);
|
---|
438 | #endif
|
---|
439 |
|
---|
440 | extern _X_EXPORT int ddxProcessArgument(int /*argc*/, char * /*argv*/ [], int /*i*/);
|
---|
441 |
|
---|
442 | extern _X_EXPORT void ddxUseMsg(void);
|
---|
443 |
|
---|
444 | /* int ReqLen(xReq *req, ClientPtr client)
|
---|
445 | * Given a pointer to a *complete* request, return its length in bytes.
|
---|
446 | * Note that if the request is a big request (as defined in the Big
|
---|
447 | * Requests extension), the macro lies by returning 4 less than the
|
---|
448 | * length that it actually occupies in the request buffer. This is so you
|
---|
449 | * can blindly compare the length with the various sz_<request> constants
|
---|
450 | * in Xproto.h without having to know/care about big requests.
|
---|
451 | */
|
---|
452 | #define ReqLen(_pxReq, _client) \
|
---|
453 | ((_pxReq->length ? \
|
---|
454 | (_client->swapped ? lswaps(_pxReq->length) : _pxReq->length) \
|
---|
455 | : ((_client->swapped ? \
|
---|
456 | lswapl(((CARD32*)_pxReq)[1]) : ((CARD32*)_pxReq)[1])-1) \
|
---|
457 | ) << 2)
|
---|
458 |
|
---|
459 | /* otherReqTypePtr CastxReq(xReq *req, otherReqTypePtr)
|
---|
460 | * Cast the given request to one of type otherReqTypePtr to access
|
---|
461 | * fields beyond the length field.
|
---|
462 | */
|
---|
463 | #define CastxReq(_pxReq, otherReqTypePtr) \
|
---|
464 | (_pxReq->length ? (otherReqTypePtr)_pxReq \
|
---|
465 | : (otherReqTypePtr)(((CARD32*)_pxReq)+1))
|
---|
466 |
|
---|
467 | /* stuff for ReplyCallback */
|
---|
468 | extern _X_EXPORT CallbackListPtr ReplyCallback;
|
---|
469 | typedef struct {
|
---|
470 | ClientPtr client;
|
---|
471 | const void *replyData;
|
---|
472 | unsigned long dataLenBytes;
|
---|
473 | unsigned long bytesRemaining;
|
---|
474 | Bool startOfReply;
|
---|
475 | } ReplyInfoRec;
|
---|
476 |
|
---|
477 | /* stuff for FlushCallback */
|
---|
478 | extern _X_EXPORT CallbackListPtr FlushCallback;
|
---|
479 |
|
---|
480 | extern _X_EXPORT void AbortDDX(void);
|
---|
481 | extern _X_EXPORT void ddxGiveUp(void);
|
---|
482 | extern _X_EXPORT int TimeSinceLastInputEvent(void);
|
---|
483 |
|
---|
484 | /* strcasecmp.c */
|
---|
485 | #if NEED_STRCASECMP
|
---|
486 | #define strcasecmp xstrcasecmp
|
---|
487 | extern _X_EXPORT int xstrcasecmp(const char *s1, const char *s2);
|
---|
488 | #endif
|
---|
489 |
|
---|
490 | #if NEED_STRNCASECMP
|
---|
491 | #define strncasecmp xstrncasecmp
|
---|
492 | extern _X_EXPORT int xstrncasecmp(const char *s1, const char *s2, size_t n);
|
---|
493 | #endif
|
---|
494 |
|
---|
495 | #if NEED_STRCASESTR
|
---|
496 | #define strcasestr xstrcasestr
|
---|
497 | extern _X_EXPORT char *xstrcasestr(const char *s, const char *find);
|
---|
498 | #endif
|
---|
499 |
|
---|
500 | #ifndef HAS_STRLCPY
|
---|
501 | extern _X_EXPORT size_t strlcpy(char *dst, const char *src, size_t siz);
|
---|
502 | extern _X_EXPORT size_t strlcat(char *dst, const char *src, size_t siz);
|
---|
503 | #endif
|
---|
504 |
|
---|
505 | /* Logging. */
|
---|
506 | typedef enum _LogParameter {
|
---|
507 | XLOG_FLUSH,
|
---|
508 | XLOG_SYNC,
|
---|
509 | XLOG_VERBOSITY,
|
---|
510 | XLOG_FILE_VERBOSITY
|
---|
511 | } LogParameter;
|
---|
512 |
|
---|
513 | /* Flags for log messages. */
|
---|
514 | typedef enum {
|
---|
515 | X_PROBED, /* Value was probed */
|
---|
516 | X_CONFIG, /* Value was given in the config file */
|
---|
517 | X_DEFAULT, /* Value is a default */
|
---|
518 | X_CMDLINE, /* Value was given on the command line */
|
---|
519 | X_NOTICE, /* Notice */
|
---|
520 | X_ERROR, /* Error message */
|
---|
521 | X_WARNING, /* Warning message */
|
---|
522 | X_INFO, /* Informational message */
|
---|
523 | X_NONE, /* No prefix */
|
---|
524 | X_NOT_IMPLEMENTED, /* Not implemented */
|
---|
525 | X_UNKNOWN = -1 /* unknown -- this must always be last */
|
---|
526 | } MessageType;
|
---|
527 |
|
---|
528 | extern _X_EXPORT const char *LogInit(const char *fname, const char *backup);
|
---|
529 | extern _X_EXPORT void LogClose(void);
|
---|
530 | extern _X_EXPORT Bool LogSetParameter(LogParameter param, int value);
|
---|
531 | extern _X_EXPORT void LogVWrite(int verb, const char *f, va_list args);
|
---|
532 | extern _X_EXPORT void LogWrite(int verb, const char *f, ...) _X_ATTRIBUTE_PRINTF(2,3);
|
---|
533 | extern _X_EXPORT void LogVMessageVerb(MessageType type, int verb, const char *format,
|
---|
534 | va_list args);
|
---|
535 | extern _X_EXPORT void LogMessageVerb(MessageType type, int verb, const char *format,
|
---|
536 | ...) _X_ATTRIBUTE_PRINTF(3,4);
|
---|
537 | extern _X_EXPORT void LogMessage(MessageType type, const char *format, ...)
|
---|
538 | _X_ATTRIBUTE_PRINTF(2,3);
|
---|
539 | extern _X_EXPORT void FreeAuditTimer(void);
|
---|
540 | extern _X_EXPORT void AuditF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2);
|
---|
541 | extern _X_EXPORT void VAuditF(const char *f, va_list args);
|
---|
542 | extern _X_EXPORT void FatalError(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2) _X_NORETURN;
|
---|
543 |
|
---|
544 | #ifdef DEBUG
|
---|
545 | #define DebugF ErrorF
|
---|
546 | #else
|
---|
547 | #define DebugF(...) /* */
|
---|
548 | #endif
|
---|
549 |
|
---|
550 | extern _X_EXPORT void VErrorF(const char *f, va_list args);
|
---|
551 | extern _X_EXPORT void ErrorF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2);
|
---|
552 | extern _X_EXPORT void Error(char *str);
|
---|
553 | extern _X_EXPORT void LogPrintMarkers(void);
|
---|
554 |
|
---|
555 | extern _X_EXPORT void xorg_backtrace(void);
|
---|
556 |
|
---|
557 | #endif /* OS_H */
|
---|