Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:26:29

0001 /*
0002  *
0003 Copyright 1989, 1998  The Open Group
0004 
0005 Permission to use, copy, modify, distribute, and sell this software and its
0006 documentation for any purpose is hereby granted without fee, provided that
0007 the above copyright notice appear in all copies and that both that
0008 copyright notice and this permission notice appear in supporting
0009 documentation.
0010 
0011 The above copyright notice and this permission notice shall be included in
0012 all copies or substantial portions of the Software.
0013 
0014 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0015 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0016 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
0017 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
0018 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
0019 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0020 
0021 Except as contained in this notice, the name of The Open Group shall not be
0022 used in advertising or otherwise to promote the sale, use or other dealings
0023 in this Software without prior written authorization from The Open Group.
0024  *
0025  * Author:  Jim Fulton, MIT The Open Group
0026  *
0027  *                     Xlib Extension-Writing Utilities
0028  *
0029  * This package contains utilities for writing the client API for various
0030  * protocol extensions.  THESE INTERFACES ARE NOT PART OF THE X STANDARD AND
0031  * ARE SUBJECT TO CHANGE!
0032  */
0033 
0034 #ifndef _EXTUTIL_H_
0035 #define _EXTUTIL_H_
0036 
0037 #include <X11/extensions/Xext.h>
0038 
0039 /*
0040  * We need to keep a list of open displays since the Xlib display list isn't
0041  * public.  We also have to per-display info in a separate block since it isn't
0042  * stored directly in the Display structure.
0043  */
0044 typedef struct _XExtDisplayInfo {
0045     struct _XExtDisplayInfo *next;  /* keep a linked list */
0046     Display *display;           /* which display this is */
0047     XExtCodes *codes;           /* the extension protocol codes */
0048     XPointer data;          /* extra data for extension to use */
0049 } XExtDisplayInfo;
0050 
0051 typedef struct _XExtensionInfo {
0052     XExtDisplayInfo *head;      /* start of list */
0053     XExtDisplayInfo *cur;       /* most recently used */
0054     int ndisplays;          /* number of displays */
0055 } XExtensionInfo;
0056 
0057 typedef struct _XExtensionHooks {
0058     int (*create_gc)(
0059           Display*          /* display */,
0060           GC            /* gc */,
0061           XExtCodes*        /* codes */
0062 );
0063     int (*copy_gc)(
0064           Display*          /* display */,
0065               GC            /* gc */,
0066               XExtCodes*        /* codes */
0067 );
0068     int (*flush_gc)(
0069           Display*          /* display */,
0070               GC            /* gc */,
0071               XExtCodes*        /* codes */
0072 );
0073     int (*free_gc)(
0074           Display*          /* display */,
0075               GC            /* gc */,
0076               XExtCodes*        /* codes */
0077 );
0078     int (*create_font)(
0079           Display*          /* display */,
0080               XFontStruct*      /* fs */,
0081               XExtCodes*        /* codes */
0082 );
0083     int (*free_font)(
0084           Display*          /* display */,
0085               XFontStruct*      /* fs */,
0086               XExtCodes*        /* codes */
0087 );
0088     int (*close_display)(
0089           Display*          /* display */,
0090               XExtCodes*        /* codes */
0091 );
0092     Bool (*wire_to_event)(
0093            Display*         /* display */,
0094                XEvent*          /* re */,
0095                xEvent*          /* event */
0096 );
0097     Status (*event_to_wire)(
0098           Display*          /* display */,
0099               XEvent*           /* re */,
0100               xEvent*           /* event */
0101 );
0102     int (*error)(
0103           Display*          /* display */,
0104               xError*           /* err */,
0105               XExtCodes*        /* codes */,
0106               int*          /* ret_code */
0107 );
0108     char *(*error_string)(
0109             Display*        /* display */,
0110                 int         /* code */,
0111                 XExtCodes*      /* codes */,
0112                 char*           /* buffer */,
0113                 int         /* nbytes */
0114 );
0115 } XExtensionHooks;
0116 
0117 extern XExtensionInfo *XextCreateExtension(
0118     void
0119 );
0120 extern void XextDestroyExtension(
0121     XExtensionInfo* /* info */
0122 );
0123 extern XExtDisplayInfo *XextAddDisplay(
0124     XExtensionInfo* /* extinfo */,
0125     Display*        /* dpy */,
0126     _Xconst char*   /* ext_name */,
0127     XExtensionHooks*    /* hooks */,
0128     int         /* nevents */,
0129     XPointer        /* data */
0130 );
0131 extern int XextRemoveDisplay(
0132     XExtensionInfo* /* extinfo */,
0133     Display*        /* dpy */
0134 );
0135 extern XExtDisplayInfo *XextFindDisplay(
0136     XExtensionInfo* /* extinfo */,
0137     Display*        /* dpy */
0138 );
0139 
0140 #define XextHasExtension(i) ((i) && ((i)->codes))
0141 #define XextCheckExtension(dpy,i,name,val) do {                            \
0142   if (!XextHasExtension(i)) { XMissingExtension (dpy, name); return val; } \
0143 } while (0)
0144 #define XextSimpleCheckExtension(dpy,i,name) do {                       \
0145   if (!XextHasExtension(i)) { XMissingExtension (dpy, name); return; }  \
0146 } while (0)
0147 
0148 
0149 /*
0150  * helper macros to generate code that is common to all extensions; caller
0151  * should prefix it with static if extension source is in one file; this
0152  * could be a utility function, but have to stack 6 unused arguments for
0153  * something that is called many, many times would be bad.
0154  */
0155 #define XEXT_GENERATE_FIND_DISPLAY(proc,extinfo,extname,hooks,nev,data) \
0156 XExtDisplayInfo *proc (Display *dpy) \
0157 { \
0158     XExtDisplayInfo *dpyinfo; \
0159     if (!extinfo) { if (!(extinfo = XextCreateExtension())) return NULL; } \
0160     if (!(dpyinfo = XextFindDisplay (extinfo, dpy))) \
0161       dpyinfo = XextAddDisplay (extinfo,dpy,extname,hooks,nev,data); \
0162     return dpyinfo; \
0163 }
0164 
0165 #define XEXT_FIND_DISPLAY_PROTO(proc) \
0166     XExtDisplayInfo *proc(Display *dpy)
0167 
0168 #define XEXT_GENERATE_CLOSE_DISPLAY(proc,extinfo) \
0169 int proc (Display *dpy, XExtCodes *codes) \
0170 { \
0171     return XextRemoveDisplay (extinfo, dpy); \
0172 }
0173 
0174 #define XEXT_CLOSE_DISPLAY_PROTO(proc) \
0175     int proc(Display *dpy, XExtCodes *codes)
0176 
0177 #define XEXT_GENERATE_ERROR_STRING(proc,extname,nerr,errl) \
0178 char *proc (Display *dpy, int code, XExtCodes *codes, char *buf, int n) \
0179 {  \
0180     code -= codes->first_error;  \
0181     if (code >= 0 && code < nerr) { \
0182     char tmp[256]; \
0183     snprintf (tmp, sizeof(tmp), "%s.%d", extname, code);            \
0184     XGetErrorDatabaseText (dpy, "XProtoError", tmp, errl[code], buf, n); \
0185     return buf; \
0186     } \
0187     return (char *)0; \
0188 }
0189 
0190 #define XEXT_ERROR_STRING_PROTO(proc) \
0191     char *proc(Display *dpy, int code, XExtCodes *codes, char *buf, int n)
0192 #endif