]> git.sesse.net Git - rdpsrv/blob - Xserver/programs/Xserver/include/os.h
Support RDP5 logon packets.
[rdpsrv] / Xserver / programs / Xserver / include / os.h
1 /***********************************************************
2
3 Copyright (c) 1987  X Consortium
4
5 Permission is hereby granted, free of charge, to any person obtaining a copy
6 of this software and associated documentation files (the "Software"), to deal
7 in the Software without restriction, including without limitation the rights
8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 copies of the Software, and to permit persons to whom the Software is
10 furnished to do so, subject to the following conditions:
11
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
14
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
18 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22 Except as contained in this notice, the name of the X Consortium shall not be
23 used in advertising or otherwise to promote the sale, use or other dealings
24 in this Software without prior written authorization from the X Consortium.
25
26
27 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
28
29                         All Rights Reserved
30
31 Permission to use, copy, modify, and distribute this software and its 
32 documentation for any purpose and without fee is hereby granted, 
33 provided that the above copyright notice appear in all copies and that
34 both that copyright notice and this permission notice appear in 
35 supporting documentation, and that the name of Digital not be
36 used in advertising or publicity pertaining to distribution of the
37 software without specific, written prior permission.  
38
39 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
40 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
41 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
42 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
43 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
44 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
45 SOFTWARE.
46
47 ******************************************************************/
48
49 /* $XConsortium: os.h /main/60 1996/12/15 21:25:13 rws $ */
50 /* $XFree86: xc/programs/Xserver/include/os.h,v 3.16.2.1 1998/01/22 10:47:13 dawes Exp $ */
51
52 #ifndef OS_H
53 #define OS_H
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 "Xalloca.h"
58
59 #define NullFID ((FID) 0)
60
61 #define SCREEN_SAVER_ON   0
62 #define SCREEN_SAVER_OFF  1
63 #define SCREEN_SAVER_FORCER 2
64 #define SCREEN_SAVER_CYCLE  3
65
66 #ifndef MAX_REQUEST_SIZE
67 #define MAX_REQUEST_SIZE 65535
68 #endif
69 #ifndef MAX_BIG_REQUEST_SIZE
70 #define MAX_BIG_REQUEST_SIZE 1048575
71 #endif
72
73 typedef pointer FID;
74 typedef struct _FontPathRec *FontPathPtr;
75 typedef struct _NewClientRec *NewClientPtr;
76
77 #define xnfalloc(size) XNFalloc((unsigned long)(size))
78 #define xnfrealloc(ptr, size) XNFrealloc((pointer)(ptr), (unsigned long)(size))
79
80 #define xalloc(size) Xalloc((unsigned long)(size))
81 #define xnfalloc(size) XNFalloc((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 xnfrealloc(ptr, size) XNFrealloc((pointer)(ptr), (unsigned long)(size))
85 #define xfree(ptr) Xfree((pointer)(ptr))
86
87 #ifdef SCO
88 #include <stdio.h>
89 #endif
90 #ifndef X_NOT_STDC_ENV
91 #include <string.h>
92 #else
93 #ifdef SYSV
94 #include <string.h>
95 #else
96 #include <strings.h>
97 #endif
98 #endif
99
100 /* have to put $(SIGNAL_DEFINES) in DEFINES in Imakefile to get this right */
101 #ifdef SIGNALRETURNSINT
102 #define SIGVAL int
103 #else
104 #define SIGVAL void
105 #endif
106
107 extern Bool OsDelayInitColors;
108
109 extern int WaitForSomething(
110 #if NeedFunctionPrototypes
111     int* /*pClientsReady*/
112 #endif
113 );
114
115 #ifdef LBX
116 #define ReadRequestFromClient(client)   ((client)->readRequest(client))
117 extern int StandardReadRequestFromClient(
118 #if NeedFunctionPrototypes
119     ClientPtr /*client*/
120 #endif
121 );
122 #else
123 extern int ReadRequestFromClient(
124 #if NeedFunctionPrototypes
125     ClientPtr /*client*/
126 #endif
127 );
128 #endif /* LBX */
129
130 extern Bool InsertFakeRequest(
131 #if NeedFunctionPrototypes
132     ClientPtr /*client*/,
133     char* /*data*/,
134     int /*count*/
135 #endif
136 );
137
138 extern int ResetCurrentRequest(
139 #if NeedFunctionPrototypes
140     ClientPtr /*client*/
141 #endif
142 );
143
144 extern void FlushAllOutput(
145 #if NeedFunctionPrototypes
146     void
147 #endif
148 );
149
150 extern void FlushIfCriticalOutputPending(
151 #if NeedFunctionPrototypes
152     void
153 #endif
154 );
155
156 extern void SetCriticalOutputPending(
157 #if NeedFunctionPrototypes
158     void
159 #endif
160 );
161
162 extern int WriteToClient(
163 #if NeedFunctionPrototypes
164     ClientPtr /*who*/,
165     int /*count*/,
166     char* /*buf*/
167 #endif
168 );
169
170 extern void ResetOsBuffers(
171 #if NeedFunctionPrototypes
172     void
173 #endif
174 );
175
176 extern void CreateWellKnownSockets(
177 #if NeedFunctionPrototypes
178     void
179 #endif
180 );
181
182 extern void ResetWellKnownSockets(
183 #if NeedFunctionPrototypes
184     void
185 #endif
186 );
187
188 extern XID
189 AuthorizationIDOfClient(
190 #if NeedFunctionPrototypes
191     ClientPtr /*client*/
192 #endif
193 );
194
195 extern char *ClientAuthorized(
196 #if NeedFunctionPrototypes
197     ClientPtr /*client*/,
198     unsigned int /*proto_n*/,
199     char* /*auth_proto*/,
200     unsigned int /*string_n*/,
201     char* /*auth_string*/
202 #endif
203 );
204
205 extern Bool EstablishNewConnections(
206 #if NeedFunctionPrototypes
207     ClientPtr /*clientUnused*/,
208     pointer /*closure*/
209 #endif
210 );
211
212 extern void CheckConnections(
213 #if NeedFunctionPrototypes
214     void
215 #endif
216 );
217
218 extern void CloseDownConnection(
219 #if NeedFunctionPrototypes
220     ClientPtr /*client*/
221 #endif
222 );
223
224 extern int AddEnabledDevice(
225 #if NeedFunctionPrototypes
226     int /*fd*/
227 #endif
228 );
229
230 extern int RemoveEnabledDevice(
231 #if NeedFunctionPrototypes
232     int /*fd*/
233 #endif
234 );
235
236 extern int OnlyListenToOneClient(
237 #if NeedFunctionPrototypes
238     ClientPtr /*client*/
239 #endif
240 );
241
242 extern int ListenToAllClients(
243 #if NeedFunctionPrototypes
244     void
245 #endif
246 );
247
248 extern int IgnoreClient(
249 #if NeedFunctionPrototypes
250     ClientPtr /*client*/
251 #endif
252 );
253
254 extern int AttendClient(
255 #if NeedFunctionPrototypes
256     ClientPtr /*client*/
257 #endif
258 );
259
260 extern int MakeClientGrabImpervious(
261 #if NeedFunctionPrototypes
262     ClientPtr /*client*/
263 #endif
264 );
265
266 extern int MakeClientGrabPervious(
267 #if NeedFunctionPrototypes
268     ClientPtr /*client*/
269 #endif
270 );
271
272 extern void Error(
273 #if NeedFunctionPrototypes
274     char* /*str*/
275 #endif
276 );
277
278 extern CARD32 GetTimeInMillis(
279 #if NeedFunctionPrototypes
280     void
281 #endif
282 );
283
284 extern int AdjustWaitForDelay(
285 #if NeedFunctionPrototypes
286     pointer /*waitTime*/,
287     unsigned long /*newdelay*/
288 #endif
289 );
290
291 typedef struct _OsTimerRec *OsTimerPtr;
292
293 typedef CARD32 (*OsTimerCallback)(
294 #if NeedFunctionPrototypes
295     OsTimerPtr /* timer */,
296     CARD32 /* time */,
297     pointer /* arg */
298 #endif
299 );
300
301 extern void TimerInit(
302 #if NeedFunctionPrototypes
303     void
304 #endif
305 );
306
307 extern Bool TimerForce(
308 #if NeedFunctionPrototypes
309     OsTimerPtr /* timer */
310 #endif
311 );
312
313 #define TimerAbsolute (1<<0)
314 #define TimerForceOld (1<<1)
315
316 extern OsTimerPtr TimerSet(
317 #if NeedFunctionPrototypes
318     OsTimerPtr /* timer */,
319     int /* flags */,
320     CARD32 /* millis */,
321     OsTimerCallback /* func */,
322     pointer /* arg */
323 #endif
324 );
325
326 extern void TimerCheck(
327 #if NeedFunctionPrototypes
328     void
329 #endif
330 );
331
332 extern void TimerCancel(
333 #if NeedFunctionPrototypes
334     OsTimerPtr /* pTimer */
335 #endif
336 );
337
338 extern void TimerFree(
339 #if NeedFunctionPrototypes
340     OsTimerPtr /* pTimer */
341 #endif
342 );
343
344 extern SIGVAL AutoResetServer(
345 #if NeedFunctionPrototypes
346     int /*sig*/
347 #endif
348 );
349
350 extern SIGVAL GiveUp(
351 #if NeedFunctionPrototypes
352     int /*sig*/
353 #endif
354 );
355
356 extern void UseMsg(
357 #if NeedFunctionPrototypes
358     void
359 #endif
360 );
361
362 extern void ProcessCommandLine(
363 #if NeedFunctionPrototypes
364     int /*argc*/,
365     char* /*argv*/[]
366 #endif
367 );
368
369 extern unsigned long *Xalloc(
370 #if NeedFunctionPrototypes
371     unsigned long /*amount*/
372 #endif
373 );
374
375 extern unsigned long *XNFalloc(
376 #if NeedFunctionPrototypes
377     unsigned long /*amount*/
378 #endif
379 );
380
381 extern unsigned long *Xcalloc(
382 #if NeedFunctionPrototypes
383     unsigned long /*amount*/
384 #endif
385 );
386
387 extern unsigned long *Xrealloc(
388 #if NeedFunctionPrototypes
389     pointer /*ptr*/,
390     unsigned long /*amount*/
391 #endif
392 );
393
394 extern unsigned long *XNFrealloc(
395 #if NeedFunctionPrototypes
396     pointer /*ptr*/,
397     unsigned long /*amount*/
398 #endif
399 );
400
401 extern void Xfree(
402 #if NeedFunctionPrototypes
403     pointer /*ptr*/
404 #endif
405 );
406
407 extern void OsInitAllocator(
408 #if NeedFunctionPrototypes
409     void
410 #endif
411 );
412
413 typedef SIGVAL (*OsSigHandlerPtr)(
414 #if NeedFunctionPrototypes
415     int /* sig */
416 #endif
417 );
418
419 extern OsSigHandlerPtr OsSignal(
420 #if NeedFunctionPrototypes
421     int /* sig */,
422     OsSigHandlerPtr /* handler */
423 #endif
424 );
425
426 extern int auditTrailLevel;
427
428 extern void AuditF(
429 #if NeedVarargsPrototypes
430     char* /*f*/,
431     ...
432 #endif
433 );
434
435 extern void FatalError(
436 #if NeedVarargsPrototypes
437     char* /*f*/,
438     ...
439 #endif
440 )
441 #if __GNUC__ == 2 && __GNUC_MINOR__ > 4 
442 __attribute((noreturn))
443 #endif
444 ;
445
446 extern void ErrorF(
447 #if NeedVarargsPrototypes
448     char* /*f*/,
449     ...
450 #endif
451 );
452
453 #ifdef SERVER_LOCK
454 extern void LockServer(
455 #if NeedFunctionPrototypes
456     void
457 #endif
458 );
459
460 extern void UnlockServer(
461 #if NeedFunctionPrototypes
462     void
463 #endif
464 );
465 #endif
466
467 extern int OsLookupColor(
468 #if NeedFunctionPrototypes
469     int /*screen*/,
470     char * /*name*/,
471     unsigned /*len*/,
472     unsigned short * /*pred*/,
473     unsigned short * /*pgreen*/,
474     unsigned short * /*pblue*/
475 #endif
476 );
477
478 extern void OsInit(
479 #if NeedFunctionPrototypes
480     void
481 #endif
482 );
483
484 extern void OsCleanup(
485 #if NeedFunctionPrototypes
486     void
487 #endif
488 );
489
490 extern void OsVendorFatalError(
491 #if NeedFunctionPrototypes
492     void
493 #endif
494 );
495
496 extern void OsVendorInit(
497 #if NeedFunctionPrototypes
498     void
499 #endif
500 );
501
502 extern int OsInitColors(
503 #if NeedFunctionPrototypes
504     void
505 #endif
506 );
507
508 #if !defined(WIN32) && !defined(__EMX__)
509 extern int System(
510 #if NeedFunctionPrototypes
511     char *
512 #endif
513 );
514
515 extern pointer Popen(
516 #if NeedFunctionPrototypes
517     char *,
518     char *
519 #endif
520 );
521
522 extern int Pclose(
523 #if NeedFunctionPrototypes
524     pointer
525 #endif
526 );
527 #else
528 #define System(a) system(a)
529 #define Popen(a,b) popen(a,b)
530 #define Pclose(a) pclose(a)
531 #endif
532
533 extern int AddHost(
534 #if NeedFunctionPrototypes
535     ClientPtr   /*client*/,
536     int         /*family*/,
537     unsigned    /*length*/,
538     pointer     /*pAddr*/
539 #endif
540 );
541
542 extern Bool ForEachHostInFamily (
543 #if NeedFunctionPrototypes
544     int     /*family*/,
545     Bool    (* /*func*/ )(
546 #if NeedNestedPrototypes
547             unsigned char * /* addr */,
548             short           /* len */,
549             pointer         /* closure */
550 #endif
551             ),
552     pointer /*closure*/
553 #endif
554 );
555
556 extern int RemoveHost(
557 #if NeedFunctionPrototypes
558     ClientPtr   /*client*/,
559     int         /*family*/,
560     unsigned    /*length*/,
561     pointer     /*pAddr*/
562 #endif
563 );
564
565 extern int GetHosts(
566 #if NeedFunctionPrototypes
567     pointer * /*data*/,
568     int     * /*pnHosts*/,
569     int     * /*pLen*/,
570     BOOL    * /*pEnabled*/
571 #endif
572 );
573
574 typedef struct sockaddr * sockaddrPtr;
575
576 extern int InvalidHost(
577 #if NeedFunctionPrototypes
578     sockaddrPtr /*saddr*/,
579     int         /*len*/
580 #endif
581 );
582
583 extern int LocalClient(
584 #if NeedFunctionPrototypes
585     ClientPtr /* client */
586 #endif
587 );
588
589 extern int ChangeAccessControl(
590 #if NeedFunctionPrototypes
591     ClientPtr /*client*/,
592     int /*fEnabled*/
593 #endif
594 );
595
596 extern int GetAccessControl(
597 #if NeedFunctionPrototypes
598     void
599 #endif
600 );
601
602
603 extern void AddLocalHosts(
604 #if NeedFunctionPrototypes
605     void
606 #endif
607 );
608
609 extern void ResetHosts(
610 #if NeedFunctionPrototypes
611     char *display
612 #endif
613 );
614
615 extern void EnableLocalHost(
616 #if NeedFunctionPrototypes
617     void
618 #endif
619 );
620
621 extern void DisableLocalHost(
622 #if NeedFunctionPrototypes
623     void
624 #endif
625 );
626
627 extern void AccessUsingXdmcp(
628 #if NeedFunctionPrototypes
629     void
630 #endif
631 );
632
633 extern void DefineSelf(
634 #if NeedFunctionPrototypes
635     int /*fd*/
636 #endif
637 );
638
639 extern void AugmentSelf(
640 #if NeedFunctionPrototypes
641     pointer /*from*/,
642     int /*len*/
643 #endif
644 );
645
646 extern void InitAuthorization(
647 #if NeedFunctionPrototypes
648     char * /*filename*/
649 #endif
650 );
651
652 extern int LoadAuthorization(
653 #if NeedFunctionPrototypes
654     void
655 #endif
656 );
657
658 extern void RegisterAuthorizations(
659 #if NeedFunctionPrototypes
660     void
661 #endif
662 );
663
664 extern XID CheckAuthorization(
665 #if NeedFunctionPrototypes
666     unsigned int /*namelength*/,
667     char * /*name*/,
668     unsigned int /*datalength*/,
669     char * /*data*/,
670     ClientPtr /*client*/,
671     char ** /*reason*/
672 #endif
673 );
674
675 extern void ResetAuthorization(
676 #if NeedFunctionPrototypes
677     void
678 #endif
679 );
680
681 extern int AddAuthorization(
682 #if NeedFunctionPrototypes
683     unsigned int /*name_length*/,
684     char * /*name*/,
685     unsigned int /*data_length*/,
686     char * /*data*/
687 #endif
688 );
689
690 extern XID GenerateAuthorization(
691 #if NeedFunctionPrototypes
692     unsigned int   /* name_length */,
693     char        *  /* name */,
694     unsigned int   /* data_length */,
695     char        *  /* data */,
696     unsigned int * /* data_length_return */,
697     char        ** /* data_return */
698 #endif
699 );
700
701 extern void ExpandCommandLine(
702 #if NeedFunctionPrototypes
703     int * /*pargc*/,
704     char *** /*pargv*/
705 #endif
706 );
707
708 extern int ddxProcessArgument(
709 #if NeedFunctionPrototypes
710     int /*argc*/,
711     char * /*argv*/ [],
712     int /*i*/
713 #endif
714 );
715
716 /*
717  *  idiom processing stuff
718  */
719
720 xReqPtr PeekNextRequest(
721 #if NeedFunctionPrototypes
722     xReqPtr req, ClientPtr client, Bool readmore
723 #endif
724 );
725
726 void SkipRequests(
727 #if NeedFunctionPrototypes
728     xReqPtr req, ClientPtr client, int numskipped
729 #endif
730 );
731
732 /* int ReqLen(xReq *req, ClientPtr client)
733  * Given a pointer to a *complete* request, return its length in bytes.
734  * Note that if the request is a big request (as defined in the Big
735  * Requests extension), the macro lies by returning 4 less than the
736  * length that it actually occupies in the request buffer.  This is so you
737  * can blindly compare the length with the various sz_<request> constants
738  * in Xproto.h without having to know/care about big requests.
739  */
740 #define ReqLen(_pxReq, _client) \
741  ((_pxReq->length ? \
742      (_client->swapped ? lswaps(_pxReq->length) : _pxReq->length) \
743   : ((_client->swapped ? \
744         lswapl(((CARD32*)_pxReq)[1]) : ((CARD32*)_pxReq)[1])-1) \
745   ) << 2)
746
747 /* otherReqTypePtr CastxReq(xReq *req, otherReqTypePtr)
748  * Cast the given request to one of type otherReqTypePtr to access
749  * fields beyond the length field.
750  */
751 #define CastxReq(_pxReq, otherReqTypePtr) \
752     (_pxReq->length ? (otherReqTypePtr)_pxReq \
753                     : (otherReqTypePtr)(((CARD32*)_pxReq)+1))
754
755 /* stuff for SkippedRequestsCallback */
756 extern CallbackListPtr SkippedRequestsCallback;
757 typedef struct {
758     xReqPtr req;
759     ClientPtr client;
760     int numskipped;
761 } SkippedRequestInfoRec;
762
763 /* stuff for ReplyCallback */
764 extern CallbackListPtr ReplyCallback;
765 typedef struct {
766     ClientPtr client;
767     pointer replyData;
768     unsigned long dataLenBytes;
769     unsigned long bytesRemaining;
770     Bool startOfReply;
771 } ReplyInfoRec;
772
773 /* stuff for FlushCallback */
774 extern CallbackListPtr FlushCallback;
775
776 #endif /* OS_H */