1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317
|
/* $Xorg: XIElibint.h,v 1.5 2001/02/09 02:03:41 xorgcvs Exp $ */
/*
Copyright 1993, 1994, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from The Open Group.
*/
/* $XFree86: xc/lib/XIE/XIElibint.h,v 3.6 2001/12/14 19:54:32 dawes Exp $ */
#ifndef _XIELIBINT_H_
#define _XIELIBINT_H_
#define NEED_REPLIES
#include <X11/Xlibint.h>
#include <X11/Xfuncs.h>
#include <X11/extensions/XIElib.h>
#include <X11/extensions/XIEproto.h>
/* -------------------------------------------------------------------------
* Display extension data structures and macros.
* ------------------------------------------------------------------------- */
/*
* For each display initialized by XieInitialize(), a record is allocated
* which holds various information about that display. These records are
* maintained in a linked list. The record for the most recently referenced
* display is always kept at the beginning of the list (for quick access).
*/
typedef struct _XieExtInfo
{
Display *display; /* pointer to X display structure */
XExtCodes *extCodes; /* extension codes */
XieExtensionInfo *extInfo; /* extension information */
struct _XieExtInfo *next; /* next in list */
} XieExtInfo;
/*
* Insert a new record in the beginning of the linked list.
*/
#define ADD_EXTENSION_INFO(_display, _info) \
\
{ \
_info->display = _display; \
\
_info->next = _XieExtInfoHeader; \
_XieExtInfoHeader = _info; \
}
/*
* Remove the record assosicated with '_display' from the linked list
* and return a pointer to it in '_info'.
*/
#define REMOVE_EXTENSION_INFO(_display, _info) \
\
{ \
XieExtInfo *prev = NULL; \
\
_info = _XieExtInfoHeader; \
\
while (_info && _info->display != _display) \
{ \
prev = _info; \
_info = _info->next; \
} \
\
if (_info) \
if (!prev) \
_XieExtInfoHeader = _info->next; \
else \
prev->next = _info->next; \
}
/*
* Return the info assosicated with '_display' in '_info'.
* If the info is not the first in the list, move it to the front.
*/
#define GET_EXTENSION_INFO(_display, _info) \
\
{ \
if ((_info = _XieExtInfoHeader)) \
{ \
if (_XieExtInfoHeader->display != _display) \
{ \
XieExtInfo *prev = _XieExtInfoHeader; \
\
_info = _info->next; \
while (_info && _info->display != _display) \
{ \
prev = _info; \
_info = _info->next; \
} \
\
if (_info) \
{ \
prev->next = _info->next; \
_info->next = _XieExtInfoHeader; \
_XieExtInfoHeader = _info; \
} \
} \
} \
}
#define PAD(_size) (3 - (((_size) + 3) & 0x3))
#define PADDED_BYTES(_bytes) (_bytes + PAD (_bytes))
#define NUMWORDS(_size) (((unsigned int) ((_size) + 3)) >> 2)
#define NUMBYTES(_len) (((unsigned int) (_len)) << 2)
#define LENOF(_ctype) (SIZEOF (_ctype) >> 2)
/* -------------------------------------------------------------------------
* Macros for setting up requests.
* ------------------------------------------------------------------------- */
/*
* Request names and opcodes.
*/
#if !defined(UNIXCPP) || defined(ANSICPP)
#define REQNAME(_name_) xie##_name_##Req
#define REQOPCODE(_name_) X_ie##_name_
#define REQSIZE(_name_) sz_xie##_name_##Req
#else
#define REQNAME(_name_) xie/**/_name_/**/Req
#define REQOPCODE(_name_) X_ie/**/_name_
#define REQSIZE(_name_) sz_xie/**/_name_/**/Req
#endif
/*
* GET_REQUEST sets up a request to be sent to the X server. If there isn't
* enough room left in the X buffer, it is flushed before the new request
* is started.
*/
#define GET_REQUEST(_name, _req) \
if ((display->bufptr + REQSIZE(_name)) > display->bufmax) \
_XFlush (display); \
_req = (char *) (display->last_req = display->bufptr); \
display->bufptr += REQSIZE(_name); \
display->request++
/*
* GET_REQUEST_EXTRA is the same as GET_REQUEST and except that an additional
* "extraBytes" are allocated after the request. "extraBytes" will be
* padded to a word boundary.
*/
#define GET_REQUEST_EXTRA(_name, _extraBytes, _req) \
if ((display->bufptr + REQSIZE(_name) + \
PADDED_BYTES (_extraBytes)) > display->bufmax) _XFlush (display); \
_req = (char *) (display->last_req = display->bufptr); \
display->bufptr += (REQSIZE(_name) + PADDED_BYTES (_extraBytes)); \
display->request++
/*
* BEGIN_REQUEST_HEADER and END_REQUEST_HEADER are used to hide
* the extra work that has to be done on 64 bit clients. On such
* machines, all structure pointers must point to an 8 byte boundary.
* As a result, we must first store the request header info in
* a static data stucture, then bcopy it into the transport buffer.
*/
#ifndef WORD64
#define BEGIN_REQUEST_HEADER(_name, _pBuf, _pReq) \
{ \
XieExtInfo *_xieExtInfo; \
GET_EXTENSION_INFO (display, _xieExtInfo); \
_pReq = (REQNAME(_name) *) _pBuf;
#define END_REQUEST_HEADER(_name, _pBuf, _pReq) \
_pBuf += REQSIZE(_name); \
}
#else /* WORD64 */
#define BEGIN_REQUEST_HEADER(_name, _pBuf, _pReq) \
{ \
XieExtInfo *_xieExtInfo; \
REQNAME(_name) tReq; \
GET_EXTENSION_INFO (display, _xieExtInfo); \
_pReq = &tReq;
#define END_REQUEST_HEADER(_name, _pBuf, _pReq) \
memcpy (_pBuf, _pReq, REQSIZE(_name)); \
_pBuf += REQSIZE(_name); \
}
#endif /* WORD64 */
/*
* Macros used to store the request header info.
*/
#define STORE_REQUEST_HEADER(_name, _req) \
_req->reqType = _xieExtInfo->extCodes->major_opcode; \
_req->opcode = REQOPCODE(_name); \
_req->length = (REQSIZE(_name)) >> 2;
#define STORE_REQUEST_EXTRA_HEADER(_name, _extraBytes, _req) \
_req->reqType = _xieExtInfo->extCodes->major_opcode; \
_req->opcode = REQOPCODE(_name); \
_req->length = (REQSIZE(_name) + PADDED_BYTES (_extraBytes)) >> 2;
typedef int (*XieTechFuncPtr) (char **, XiePointer, int);
typedef struct _XieTechFuncRec {
int technique;
XieTechFuncPtr techfunc;
struct _XieTechFuncRec *next;
} XieTechFuncRec;
/*
* See if XSynchronize has been called. If so, send request right away.
*/
#define SYNC_HANDLE(_display)\
if ((_display)->synchandler) (*(_display)->synchandler) (_display)
/*
* Read a reply into a scratch buffer.
*/
#define XREAD_INTO_SCRATCH(_display, _pBuf, _numBytes) \
_pBuf = (char *) _XAllocTemp (_display, _numBytes); \
_XRead (_display, _pBuf, _numBytes);
#define FINISH_WITH_SCRATCH(_display, _pBuf, _numBytes) \
_XFreeTemp (_display, _pBuf, _numBytes);
/*
* Externally defined globals
*/
extern XieExtInfo *_XieExtInfoHeader;
extern void (*(_XieElemFuncs[]))(char **, XiePhotoElement *);
extern XieTechFuncRec *_XieTechFuncs[];
extern Bool _XieTechFuncsInitialized;
extern Bool _XieFloError (Display *, XErrorEvent *, xError *);
extern Status _XieColorAllocEvent (Display *, XEvent *, xEvent *);
extern Status _XieDecodeNotifyEvent (Display *, XEvent *, xEvent *);
extern Status _XieExportAvailableEvent (Display *, XEvent *, xEvent *);
extern Status _XieImportObscuredEvent (Display *, XEvent *, xEvent *);
extern Status _XiePhotofloDoneEvent (Display *, XEvent *, xEvent *);
extern Status _XieRegisterTechFunc (int, int, XieTechFuncPtr);
extern XieTechFuncPtr _XieLookupTechFunc (int, int);
extern int _XieCloseDisplay (Display *, XExtCodes *);
extern int _XiePhotofloSize (XiePhotoElement *, int);
extern int _XieTechniqueLength (int, int, XiePointer);
extern void _XieEncodeTechnique (char **, int, int, XiePointer);
extern void _XieInitTechFuncTable (void);
extern void _XiePrintError (Display *display, XErrorEvent *error, void *fp);
extern xieTypFloat _XieConvertToIEEE(double);
/* for X-Window system protocol elements */
#define sz_CARD32 4
#define sz_CARD16 2
#define sz_CARD8 1
#define sz_INT32 4
#define sz_INT16 2
#endif /* _XIELIBINT_H_ */
|