]> git.sesse.net Git - rdpsrv/blob - Xserver/include/extensions/extutil.h
Support RDP5 logon packets.
[rdpsrv] / Xserver / include / extensions / extutil.h
1 /*
2  * $XConsortium: extutil.h,v 1.15 94/10/07 15:36:33 kaleb Exp $
3  *
4 Copyright (c) 1989  X Consortium
5
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
19 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23 Except as contained in this notice, the name of the X Consortium shall not be
24 used in advertising or otherwise to promote the sale, use or other dealings
25 in this Software without prior written authorization from the X Consortium.
26  *
27  * Author:  Jim Fulton, MIT X Consortium
28  * 
29  *                     Xlib Extension-Writing Utilities
30  *
31  * This package contains utilities for writing the client API for various
32  * protocol extensions.  THESE INTERFACES ARE NOT PART OF THE X STANDARD AND
33  * ARE SUBJECT TO CHANGE!
34  */
35
36 #ifndef _EXTUTIL_H_
37 #define _EXTUTIL_H_
38
39 /*
40  * We need to keep a list of open displays since the Xlib display list isn't
41  * public.  We also have to per-display info in a separate block since it isn't
42  * stored directly in the Display structure.
43  */
44 typedef struct _XExtDisplayInfo {
45     struct _XExtDisplayInfo *next;      /* keep a linked list */
46     Display *display;                   /* which display this is */
47     XExtCodes *codes;                   /* the extension protocol codes */
48     XPointer data;                      /* extra data for extension to use */
49 } XExtDisplayInfo;
50
51 typedef struct _XExtensionInfo {
52     XExtDisplayInfo *head;              /* start of list */
53     XExtDisplayInfo *cur;               /* most recently used */
54     int ndisplays;                      /* number of displays */
55 } XExtensionInfo;
56
57 typedef struct _XExtensionHooks {
58     int (*create_gc)(
59 #if NeedNestedPrototypes
60               Display*                  /* display */,
61               GC                        /* gc */,
62               XExtCodes*                /* codes */
63 #endif
64 );
65     int (*copy_gc)(
66 #if NeedNestedPrototypes
67               Display*                  /* display */,
68               GC                        /* gc */,
69               XExtCodes*                /* codes */
70 #endif
71 );
72     int (*flush_gc)(
73 #if NeedNestedPrototypes
74               Display*                  /* display */,
75               GC                        /* gc */,
76               XExtCodes*                /* codes */
77 #endif
78 );
79     int (*free_gc)(
80 #if NeedNestedPrototypes
81               Display*                  /* display */,
82               GC                        /* gc */,
83               XExtCodes*                /* codes */
84 #endif
85 );
86     int (*create_font)(
87 #if NeedNestedPrototypes
88               Display*                  /* display */,
89               XFontStruct*              /* fs */,
90               XExtCodes*                /* codes */
91 #endif
92 );
93     int (*free_font)(
94 #if NeedNestedPrototypes
95               Display*                  /* display */,
96               XFontStruct*              /* fs */,
97               XExtCodes*                /* codes */
98 #endif
99 );
100     int (*close_display)(
101 #if NeedNestedPrototypes
102               Display*                  /* display */,
103               XExtCodes*                /* codes */
104 #endif
105 );
106     Bool (*wire_to_event)(
107 #if NeedNestedPrototypes
108                Display*                 /* display */,
109                XEvent*                  /* re */,
110                xEvent*                  /* event */
111 #endif
112 );
113     Status (*event_to_wire)(
114 #if NeedNestedPrototypes
115               Display*                  /* display */,
116               XEvent*                   /* re */,
117               xEvent*                   /* event */
118 #endif
119 );
120     int (*error)(
121 #if NeedNestedPrototypes
122               Display*                  /* display */,
123               xError*                   /* err */,
124               XExtCodes*                /* codes */,
125               int*                      /* ret_code */
126 #endif
127 );
128     char *(*error_string)(
129 #if NeedNestedPrototypes
130                 Display*                /* display */,
131                 int                     /* code */,
132                 XExtCodes*              /* codes */,
133                 char*                   /* buffer */,
134                 int                     /* nbytes */
135 #endif
136 );
137 } XExtensionHooks;
138
139 extern XExtensionInfo *XextCreateExtension(
140 #if NeedFunctionPrototypes
141     void
142 #endif
143 );
144 extern void XextDestroyExtension(
145 #if NeedFunctionPrototypes
146     XExtensionInfo*     /* info */
147 #endif
148 );
149 extern XExtDisplayInfo *XextAddDisplay(
150 #if NeedFunctionPrototypes
151     XExtensionInfo*     /* extinfo */,
152     Display*            /* dpy */,
153     char*               /* ext_name */,
154     XExtensionHooks*    /* hooks */,
155     int                 /* nevents */,
156     XPointer            /* data */
157 #endif
158 );
159 extern int XextRemoveDisplay(
160 #if NeedFunctionPrototypes
161     XExtensionInfo*     /* extinfo */,
162     Display*            /* dpy */
163 #endif
164 );
165 extern XExtDisplayInfo *XextFindDisplay(
166 #if NeedFunctionPrototypes
167     XExtensionInfo*     /* extinfo */,
168     Display*            /* dpy */
169 #endif
170 );
171
172 #define XextHasExtension(i) ((i) && ((i)->codes))
173 #define XextCheckExtension(dpy,i,name,val) \
174   if (!XextHasExtension(i)) { XMissingExtension (dpy, name); return val; }
175 #define XextSimpleCheckExtension(dpy,i,name) \
176   if (!XextHasExtension(i)) { XMissingExtension (dpy, name); return; }
177
178
179 /*
180  * helper macros to generate code that is common to all extensions; caller
181  * should prefix it with static if extension source is in one file; this
182  * could be a utility function, but have to stack 6 unused arguments for 
183  * something that is called many, many times would be bad.
184  */
185 #define XEXT_GENERATE_FIND_DISPLAY(proc,extinfo,extname,hooks,nev,data) \
186 XExtDisplayInfo *proc (dpy) \
187     register Display *dpy; \
188 { \
189     XExtDisplayInfo *dpyinfo; \
190     if (!extinfo) { if (!(extinfo = XextCreateExtension())) return NULL; } \
191     if (!(dpyinfo = XextFindDisplay (extinfo, dpy))) \
192       dpyinfo = XextAddDisplay (extinfo,dpy,extname,hooks,nev,data); \
193     return dpyinfo; \
194 }
195
196 #define XEXT_GENERATE_CLOSE_DISPLAY(proc,extinfo) \
197 int proc (dpy, codes) \
198     Display *dpy; \
199     XExtCodes *codes; \
200 { \
201     return XextRemoveDisplay (extinfo, dpy); \
202 }
203
204 #define XEXT_GENERATE_ERROR_STRING(proc,extname,nerr,errl) \
205 char *proc (dpy, code, codes, buf, n) \
206     Display  *dpy; \
207     int code; \
208     XExtCodes *codes; \
209     char *buf; \
210     int n; \
211 {  \
212     code -= codes->first_error;  \
213     if (code >= 0 && code < nerr) { \
214         char tmp[256]; \
215         sprintf (tmp, "%s.%d", extname, code); \
216         XGetErrorDatabaseText (dpy, "XProtoError", tmp, errl[code], buf, n); \
217         return buf; \
218     } \
219     return (char *)0; \
220 }
221
222 #endif