/* Xlib function entries */

#include "../c/eus.h"
#include <dlfcn.h>
#pragma init (init_object_module)

/*  EusLisp X window entries */
/*  This file is needed to be linked with Xfdreign in order to
/*  extract Xlib functions from the archive.
/*  XVERSION should be set properly when compiled.
/*  1988-Dec (c) T.MATSUI
*/

extern int XDeleteContext;
extern int XFindContext;
extern int XSaveContext;
extern int XrmParseCommand;
extern int Xpermalloc;
extern int XrmQuarkToString;
extern int XrmStringToQuark;
extern int XrmUniqueQuark;
extern int XAllocColorCells;
extern int XAllocColorPlanes;
extern int XAllowEvents;
extern int XAutoRepeatOff;
extern int XAutoRepeatOn;
extern int XSetWindowBackground;
extern int XSetWindowBorderWidth;
extern int XBell;
extern int XSetWindowBorder;
extern int XDisableAccessControl;
extern int XEnableAccessControl;
extern int XSetAccessControl;
extern int XSetCloseDownMode;
extern int XChangeActivePointerGrab;
extern int XSetWindowColormap;
extern int XChangeGC;
extern int XChangeKeyboardControl;
extern int XChangePointerControl;
extern int XChangeProperty;
extern int XAddToSaveSet;
extern int XChangeSaveSet;
extern int XRemoveFromSaveSet;
extern int XChangeWindowAttributes;
extern int XResizeWindow;
extern int XCheckIfEvent;
extern int XCheckMaskEvent;
extern int XCheckWindowEvent;
extern int XCheckTypedEvent;
extern int XCheckTypedWindowEvent;
extern int XCirculateSubwindows;
extern int XCirculateSubwindowsDown;
extern int XCirculateSubwindowsUp;
extern int XCloseDisplay;
extern int XClearWindow;
extern int XClearArea;
extern int XMoveResizeWindow;
extern int XConvertSelection;
extern int XCopyArea;
extern int XCopyColormapAndFree;
extern int XCopyGC;
extern int XCopyPlane;
extern int XCreateBitmapFromData;
extern int XCreateColormap;
extern int XCreatePixmapCursor;
extern int XCreateGC;
extern int XGContextFromGC;
extern int XCreateGlyphCursor;
extern int XCreatePixmapFromBitmapData;
extern int XCreatePixmap;
extern int XCreateSimpleWindow;
extern int XCreateFontCursor;
extern int XDefineCursor;
extern int XDeleteProperty;
extern int XDestroySubwindows;
extern int XDestroyWindow;
extern int XDisplayName;
extern int XDrawArc;
extern int XDrawArcs;
extern int XDrawLine;
extern int XDrawLines;
extern int XDrawPoint;
extern int XDrawPoints;
extern int XDrawRectangle;
extern int XDrawRectangles;
extern int XDrawSegments;
extern int XGetErrorDatabaseText;
extern int XGetErrorText;
extern int XSetErrorHandler;
extern int XSetIOErrorHandler;
extern int XFetchName;
extern int XGetIconName;
extern int XFillArc;
extern int XFillArcs;
extern int XFillPolygon;
extern int XFillRectangle;
extern int XFillRectangles;
extern int XFlush;
extern int XFreeFont;
extern int XLoadQueryFont;
extern int XQueryFont;
extern int XFreeFontNames;
extern int XListFonts;
extern int XFreeFontInfo;
extern int XListFontsWithInfo;
extern int XFreeColormap;
extern int XFreeColors;
extern int XFreeCursor;
extern int XFreeGC;
extern int XFreePixmap;
extern int XActivateScreenSaver;
extern int XForceScreenSaver;
extern int XResetScreenSaver;
extern int XSetArcMode;
extern int XSetFillRule;
extern int XSetFillStyle;
extern int XSetGraphicsExposures;
extern int XSetSubwindowMode;
extern int XGeometry;
extern int XGetAtomName;
extern int XAllocNamedColor;
extern int XGetDefault;
extern int XFreeFontPath;
extern int XGetFontPath;
extern int XGetFontProperty;
extern int XGetGeometry;
extern int XGetGCValues;
extern int XAllocColor;
extern int XGetClassHint;
extern int XGetIconSizes;
extern int XGetNormalHints;
extern int XGetSizeHints;
extern int XGetTransientForHint;
extern int XGetWMHints;
extern int XGetZoomHints;
extern int XGetInputFocus;
extern int XGetImage;
extern int XGetSubImage;
extern int XGetKeyboardControl;
extern int XGetMotionEvents;
extern int XGetPointerControl;
extern int XGetKeyboardMapping;
extern int XGetPointerMapping;
extern int XGetWindowProperty;
extern int XGetSelectionOwner;
extern int XGetScreenSaver;
extern int XGetStandardColormap;
extern int XGetWindowAttributes;
extern int XGrabButton;
extern int XGrabKey;
extern int XGrabKeyboard;
extern int XGrabPointer;
extern int XGrabServer;
extern int XAddHost;
extern int XAddHosts;
extern int XRemoveHost;
extern int XRemoveHosts;
extern int XIfEvent;
extern int XCreateImage;
extern int XDrawImageString;
extern int XDrawImageString16;
extern int XESetCloseDisplay;
extern int XESetCopyGC;
extern int XESetCreateFont;
extern int XESetCreateGC;
extern int XESetError;
extern int XESetErrorString;
extern int XESetEventToWire;
extern int XESetFlushGC;
extern int XESetFreeFont;
extern int XESetFreeGC;
extern int XESetWireToEvent;
extern int XInitExtension;
extern int XInstallColormap;
extern int XInternAtom;

#ifdef X_V11R2
extern int MatchEvent;
#endif 

extern int XKeycodeToKeysym;
extern int XKeysymToKeycode;
extern int XLookupKeysym;
extern int XLookupString;
extern int XRebindKeysym;
extern int XRefreshKeyboardMapping;
/* extern int XUseKeymap; */
extern int XKillClient;
extern int XListHosts;
extern int XListInstalledColormaps;
extern int XListProperties;
extern int XFreeExtensionList;
extern int XListExtensions;
extern int XLoadFont;
extern int XLookupColor;
extern int XLowerWindow;
extern int XAddPixel;
extern int XAllPlanes;
extern int XBitmapBitOrder;
extern int XBitmapPad;
extern int XBitmapUnit;
extern int XBlackPixel;
extern int XBlackPixelOfScreen;
extern int XCellsOfScreen;
extern int XConnectionNumber;
extern int XDefaultColormap;
extern int XDefaultColormapOfScreen;
extern int XDefaultDepth;
extern int XDefaultDepthOfScreen;
extern int XDefaultGC;
extern int XDefaultGCOfScreen;
extern int XDefaultRootWindow;
extern int XDefaultScreen;
extern int XDefaultScreenOfDisplay;
extern int XDefaultVisual;
extern int XDefaultVisualOfScreen;
extern int XDestroyImage;
extern int XDisplayCells;
extern int XDisplayHeight;
extern int XDisplayHeightMM;
extern int XDisplayOfScreen;
extern int XDisplayPlanes;
extern int XDisplayString;
extern int XDisplayWidth;
extern int XDisplayWidthMM;
extern int XDoesBackingStore;
extern int XDoesSaveUnders;
extern int XEventMaskOfScreen;
extern int XGetPixel;
extern int XHeightMMOfScreen;
extern int XHeightOfScreen;
extern int XImageByteOrder;
extern int XLastKnownRequestProcessed;
extern int XMaxCmapsOfScreen;
extern int XMinCmapsOfScreen;
extern int XNextRequest;
extern int XNoOp;
extern int XPlanesOfScreen;
extern int XProtocolRevision;
extern int XProtocolVersion;
extern int XPutPixel;
extern int XQLength;
extern int XRootWindow;
extern int XRootWindowOfScreen;
extern int XScreenCount;
extern int XScreenOfDisplay;
extern int XServerVendor;
extern int XSubImage;
extern int XVendorRelease;
extern int XWhitePixel;
extern int XWhitePixelOfScreen;
extern int XWidthMMOfScreen;
extern int XWidthOfScreen;
extern int XMapRaised;
extern int XMapSubwindows;
extern int XMapWindow;
extern int XMaskEvent;
extern int XDeleteModifiermapEntry;
extern int XFreeModifiermap;
extern int XGetModifierMapping;
extern int XInsertModifiermapEntry;
extern int XNewModifiermap;
extern int XSetModifierMapping;
extern int XMoveWindow;
extern int XNextEvent;
extern int XOpenDisplay;
extern int XParseColor;
/* extern int ReadInteger; */
extern int XParseGeometry;
extern int XPeekEvent;
extern int XPeekIfEvent;
extern int XEventsQueued;
extern int XPending;
extern int XSetWindowBackgroundPixmap;
extern int XSetWindowBorderPixmap;
extern int XPolygonRegion;
extern int XDrawText;
extern int XDrawText16;
extern int XPutBackEvent;
extern int XPutImage;
extern int XQueryBestSize;
extern int XQueryColor;
extern int XQueryColors;
extern int XQueryBestCursor;
extern int XQueryExtension;
extern int XQueryKeymap;
extern int XQueryPointer;
extern int XQueryBestStipple;
extern int XQueryTextExtents16;
extern int XQueryTextExtents;
extern int XQueryBestTile;
extern int XQueryTree;
extern int XRaiseWindow;
extern int XReadBitmapFile;
extern int XRecolorCursor;
extern int XConfigureWindow;
extern int XClipBox;
extern int XCreateRegion;
extern int XDestroyRegion;
extern int XEmptyRegion;
extern int XEqualRegion;
extern int XIntersectRegion;
extern int XOffsetRegion;
extern int XPointInRegion;
extern int XRectInRegion;
extern int XSetRegion;
extern int XShrinkRegion;
extern int XSubtractRegion;
extern int XUnionRectWithRegion;
extern int XUnionRegion;
extern int XXorRegion;
/* extern int combineRegs; */
extern int XReparentWindow;
extern int XRestackWindows;
extern int XRotateWindowProperties;
extern int XSelectInput;
extern int XSendEvent;
extern int XSetBackground;
extern int XSetClipRectangles;
extern int XSetClipMask;
extern int XSetClipOrigin;
extern int XSetDashes;
extern int XSetFontPath;
extern int XSetFont;
extern int XSetForeground;
extern int XSetFunction;
extern int XSetClassHint;
extern int XSetCommand;
extern int XSetIconSizes;
extern int XSetNormalHints;
extern int XSetSizeHints;
extern int XSetStandardProperties;
extern int XSetTransientForHint;
extern int XSetWMHints;
extern int XSetZoomHints;
extern int XSetInputFocus;
extern int XSetLineAttributes;
extern int XSetPlaneMask;
extern int XChangeKeyboardMapping;
extern int XSetPointerMapping;
extern int XSetSelectionOwner;
extern int XSetScreenSaver;
extern int XSetState;
extern int XSetStipple;
extern int XSetStandardColormap;
extern int XSetTile;
extern int XSetTSOrigin;
extern int XFetchBuffer;
extern int XFetchBytes;
extern int XRotateBuffers;
extern int XStoreBuffer;
extern int XStoreBytes;
extern int XStoreColor;
extern int XStoreColors;
extern int XStoreNamedColor;
extern int XSetIconName;
extern int XStoreName;
extern int XKeysymToString;
extern int XStringToKeysym;
extern int XSync;
extern int XSetAfterFunction;
extern int XSynchronize;
extern int XDrawString;
extern int XDrawString16;
extern int XTextExtents;
extern int XTextWidth;
extern int XTextExtents16;
extern int XTextWidth16;
extern int XTranslateCoordinates;
extern int XUndefineCursor;
extern int XUngrabButton;
extern int XUngrabKeyboard;
extern int XUngrabKey;
extern int XUngrabPointer;
extern int XUngrabServer;
extern int XUninstallColormap;
extern int XUnloadFont;
extern int XUnmapSubwindows;
extern int XUnmapWindow;
extern int XGetVisualInfo;
extern int XMatchVisualInfo;
extern int XWarpPointer;
extern int XWindowEvent;
extern int XCreateWindow;
extern int XWriteBitmapFile;
extern int XFree;
extern int XrmGetFileDatabase;
extern int XrmGetResource;
extern int XrmGetStringDatabase;
extern int XrmInitialize;
extern int XrmMergeDatabases;
extern int XrmPutFileDatabase;
extern int XrmPutLineResource;
extern int XrmPutResource;
extern int XrmPutStringResource;
extern int XrmQGetResource;
extern int XrmQGetSearchList;
extern int XrmQGetSearchResource;
extern int XrmQPutResource;
extern int XrmQPutStringResource;
extern int XrmStringToBindingQuarkList;
extern int XrmStringToQuarkList;
#if X_V11R6_1
extern int XInitThreads;
extern int XLockDisplay;
extern int XUnlockDisplay;
#endif


extern pointer sysmod;

pointer defxforeign(ctx,xentry)
register context *ctx;
char *xentry;
{ pointer fc, xsym;
  eusinteger_t entry; int i, len;
  char lname[100];
  len=strlen(xentry);
  for (i=0; i<len-1; i++) lname[i]=toupper(xentry[i+1]);
  lname[i]=0;
#if Cygwin /* dlopen libX11.dll */
   eusinteger_t dlhandle;
   dlhandle=(eusinteger_t)dlopen("/usr/bin/cygX11-6.dll", RTLD_LAZY);
   if( dlhandle==0 )
     dlhandle=(eusinteger_t)dlopen("libX11.dll", RTLD_LAZY);
   entry=(eusinteger_t)dlsym(dlhandle, xentry);
#elif Darwin
   eusinteger_t dlhandle;
   dlhandle=(eusinteger_t)dlopen("/opt/X11/lib/libX11.dylib", RTLD_LAZY);
   if( dlhandle==0 )
     dlhandle=(eusinteger_t)dlopen("/usr/local/lib/libX11.dylib", RTLD_LAZY);
   if( dlhandle==0 )
     dlhandle=(eusinteger_t)dlopen("libX11.dylib", RTLD_LAZY);
   entry=(eusinteger_t)dlsym(dlhandle, xentry);
#else
  entry=(eusinteger_t)dlsym((void *)((eusinteger_t)(sysmod->c.ldmod.handle) & ~3), xentry);
#endif
  if (entry){
    xsym=intern(ctx,lname, len-1, xpkg);
    fc=makeobject(C_FCODE);
    xsym->c.sym.spefunc=fc;
    fc->c.fcode.codevec=makeint(0);
    fc->c.fcode.quotevec=makeint(0);
    fc->c.fcode.subrtype=SUBR_FUNCTION;
    fc->c.fcode.paramtypes=NIL;
    fc->c.fcode.resulttype=K_INTEGER;
    fc->c.fcode.entry=makeint(entry>>2);
    fc->c.fcode.entry2=makeint(entry);   /* kanehiro's patch 2000.12.13 */
/*  
    printf("x: %s at %x, %x\n", xsym->c.sym.pname->c.str.chars, 
                                entry, fc->c.fcode.entry); 
*/
    export(xsym,xpkg); 
  }
  return(xsym);}
  
pointer xforeign(ctx,n,argv)
register context *ctx;
int n;
pointer argv[];
{
  defxforeign(ctx,"XDeleteContext");
  defxforeign(ctx,"XFindContext");
  defxforeign(ctx,"XSaveContext");
  defxforeign(ctx,"XrmParseCommand");
  defxforeign(ctx,"Xpermalloc");
  defxforeign(ctx,"XrmQuarkToString");
  defxforeign(ctx,"XrmStringToQuark");
  defxforeign(ctx,"XrmUniqueQuark");
  defxforeign(ctx,"XAllocColorCells");
  defxforeign(ctx,"XAllocColorPlanes");
  defxforeign(ctx,"XAllowEvents");
  defxforeign(ctx,"XAutoRepeatOff");
  defxforeign(ctx,"XAutoRepeatOn");
  defxforeign(ctx,"XSetWindowBackground");
  defxforeign(ctx,"XSetWindowBorderWidth");
  defxforeign(ctx,"XBell");
  defxforeign(ctx,"XSetWindowBorder");
  defxforeign(ctx,"XDisableAccessControl");
  defxforeign(ctx,"XEnableAccessControl");
  defxforeign(ctx,"XSetAccessControl");
  defxforeign(ctx,"XSetCloseDownMode");
  defxforeign(ctx,"XChangeActivePointerGrab");
  defxforeign(ctx,"XSetWindowColormap");
  defxforeign(ctx,"XChangeGC");
  defxforeign(ctx,"XGetGCValues");
  defxforeign(ctx,"XChangeKeyboardControl");
  defxforeign(ctx,"XChangePointerControl");
  defxforeign(ctx,"XChangeProperty");
  defxforeign(ctx,"XAddToSaveSet");
  defxforeign(ctx,"XChangeSaveSet");
  defxforeign(ctx,"XRemoveFromSaveSet");
  defxforeign(ctx,"XChangeWindowAttributes");
  defxforeign(ctx,"XResizeWindow");
  defxforeign(ctx,"XCheckIfEvent");
  defxforeign(ctx,"XCheckMaskEvent");
  defxforeign(ctx,"XCheckWindowEvent");
  defxforeign(ctx,"XCheckTypedEvent");
  defxforeign(ctx,"XCheckTypedWindowEvent");
  defxforeign(ctx,"XCirculateSubwindows");
  defxforeign(ctx,"XCirculateSubwindowsDown");
  defxforeign(ctx,"XCirculateSubwindowsUp");
  defxforeign(ctx,"XCloseDisplay");
  defxforeign(ctx,"XClearWindow");
  defxforeign(ctx,"XClearArea");
  defxforeign(ctx,"XMoveResizeWindow");
  defxforeign(ctx,"XConvertSelection");
  defxforeign(ctx,"XCopyArea");
  defxforeign(ctx,"XCopyColormapAndFree");
  defxforeign(ctx,"XCopyGC");
  defxforeign(ctx,"XCopyPlane");
  defxforeign(ctx,"XCreateBitmapFromData");
  defxforeign(ctx,"XCreateColormap");
  defxforeign(ctx,"XCreatePixmapCursor");
  defxforeign(ctx,"XCreateGC");
  defxforeign(ctx,"XGContextFromGC");
  defxforeign(ctx,"XCreateGlyphCursor");
  defxforeign(ctx,"XCreatePixmapFromBitmapData");
  defxforeign(ctx,"XCreatePixmap");
  defxforeign(ctx,"XCreateSimpleWindow");
  defxforeign(ctx,"XCreateFontCursor");
  defxforeign(ctx,"XDefineCursor");
  defxforeign(ctx,"XDeleteProperty");
  defxforeign(ctx,"XDestroySubwindows");
  defxforeign(ctx,"XDestroyWindow");
  defxforeign(ctx,"XDisplayName");
  defxforeign(ctx,"XDrawArc");
  defxforeign(ctx,"XDrawArcs");
  defxforeign(ctx,"XDrawLine");
  defxforeign(ctx,"XDrawLines");
  defxforeign(ctx,"XDrawPoint");
  defxforeign(ctx,"XDrawPoints");
  defxforeign(ctx,"XDrawRectangle");
  defxforeign(ctx,"XDrawRectangles");
  defxforeign(ctx,"XDrawSegments");
  defxforeign(ctx,"XGetErrorDatabaseText");
  defxforeign(ctx,"XGetErrorText");
  defxforeign(ctx,"XSetErrorHandler");
  defxforeign(ctx,"XSetIOErrorHandler");
  defxforeign(ctx,"XFetchName");
  defxforeign(ctx,"XGetIconName");
  defxforeign(ctx,"XFillArc");
  defxforeign(ctx,"XFillArcs");
  defxforeign(ctx,"XFillPolygon");
  defxforeign(ctx,"XFillRectangle");
  defxforeign(ctx,"XFillRectangles");
  defxforeign(ctx,"XFlush");
  defxforeign(ctx,"XFreeFont");
  defxforeign(ctx,"XLoadQueryFont");
  defxforeign(ctx,"XQueryFont");
  defxforeign(ctx,"XFreeFontNames");
  defxforeign(ctx,"XListFonts");
  defxforeign(ctx,"XFreeFontInfo");
  defxforeign(ctx,"XListFontsWithInfo");
  defxforeign(ctx,"XFreeColormap");
  defxforeign(ctx,"XFreeColors");
  defxforeign(ctx,"XFreeCursor");
  defxforeign(ctx,"XFreeGC");
  defxforeign(ctx,"XFreePixmap");
  defxforeign(ctx,"XActivateScreenSaver");
  defxforeign(ctx,"XForceScreenSaver");
  defxforeign(ctx,"XResetScreenSaver");
  defxforeign(ctx,"XSetArcMode");
  defxforeign(ctx,"XSetFillRule");
  defxforeign(ctx,"XSetFillStyle");
  defxforeign(ctx,"XSetGraphicsExposures");
  defxforeign(ctx,"XSetSubwindowMode");
  defxforeign(ctx,"XGeometry");
  defxforeign(ctx,"XGetAtomName");
  defxforeign(ctx,"XAllocNamedColor");
  defxforeign(ctx,"XGetDefault");
  defxforeign(ctx,"XFreeFontPath");
  defxforeign(ctx,"XGetFontPath");
  defxforeign(ctx,"XGetFontProperty");
  defxforeign(ctx,"XGetGeometry");
  defxforeign(ctx,"XAllocColor");
  defxforeign(ctx,"XGetClassHint");
  defxforeign(ctx,"XGetIconSizes");
  defxforeign(ctx,"XGetNormalHints");
  defxforeign(ctx,"XGetSizeHints");
  defxforeign(ctx,"XGetTransientForHint");
  defxforeign(ctx,"XGetWMHints");
  defxforeign(ctx,"XGetZoomHints");
  defxforeign(ctx,"XGetInputFocus");
  defxforeign(ctx,"XGetImage");
  defxforeign(ctx,"XGetSubImage");
  defxforeign(ctx,"XGetKeyboardControl");
  defxforeign(ctx,"XGetMotionEvents");
  defxforeign(ctx,"XGetPointerControl");
  defxforeign(ctx,"XGetKeyboardMapping");
  defxforeign(ctx,"XGetPointerMapping");
  defxforeign(ctx,"XGetWindowProperty");
  defxforeign(ctx,"XGetSelectionOwner");
  defxforeign(ctx,"XGetScreenSaver");
  defxforeign(ctx,"XGetStandardColormap");
  defxforeign(ctx,"XGetWindowAttributes");
  defxforeign(ctx,"XGrabButton");
  defxforeign(ctx,"XGrabKey");
  defxforeign(ctx,"XGrabKeyboard");
  defxforeign(ctx,"XGrabPointer");
  defxforeign(ctx,"XGrabServer");
  defxforeign(ctx,"XAddHost");
  defxforeign(ctx,"XAddHosts");
  defxforeign(ctx,"XRemoveHost");
  defxforeign(ctx,"XRemoveHosts");
  defxforeign(ctx,"XIfEvent");
  defxforeign(ctx,"XCreateImage");
  defxforeign(ctx,"XDrawImageString");
  defxforeign(ctx,"XDrawImageString16");
  defxforeign(ctx,"XESetCloseDisplay");
  defxforeign(ctx,"XESetCopyGC");
  defxforeign(ctx,"XESetCreateFont");
  defxforeign(ctx,"XESetCreateGC");
  defxforeign(ctx,"XESetError");
  defxforeign(ctx,"XESetErrorString");
  defxforeign(ctx,"XESetEventToWire");
  defxforeign(ctx,"XESetFlushGC");
  defxforeign(ctx,"XESetFreeFont");
  defxforeign(ctx,"XESetFreeGC");
  defxforeign(ctx,"XESetWireToEvent");
  defxforeign(ctx,"XInitExtension");
  defxforeign(ctx,"XInstallColormap");
  defxforeign(ctx,"XInternAtom");

  defxforeign(ctx,"XKeycodeToKeysym");
  defxforeign(ctx,"XKeysymToKeycode");
  defxforeign(ctx,"XLookupKeysym");
  defxforeign(ctx,"XLookupString");
  defxforeign(ctx,"XRebindKeysym");
  defxforeign(ctx,"XRefreshKeyboardMapping");
/* usekeymap cannot be found in X11R4 */
/*   (defxforeign USEKEYMAP Xlib "XKillClient"); */
  defxforeign(ctx,"XListHosts");
  defxforeign(ctx,"XListInstalledColormaps");
  defxforeign(ctx,"XListProperties");
  defxforeign(ctx,"XFreeExtensionList");
  defxforeign(ctx,"XListExtensions");
  defxforeign(ctx,"XLoadFont");
  defxforeign(ctx,"XLookupColor");
  defxforeign(ctx,"XLowerWindow");
  defxforeign(ctx,"XAddPixel");
  defxforeign(ctx,"XAllPlanes");
  defxforeign(ctx,"XBitmapBitOrder");
  defxforeign(ctx,"XBitmapPad");
  defxforeign(ctx,"XBitmapUnit");
  defxforeign(ctx,"XBlackPixel");
  defxforeign(ctx,"XBlackPixelOfScreen");
  defxforeign(ctx,"XCellsOfScreen");
  defxforeign(ctx,"XConnectionNumber");
  defxforeign(ctx,"XDefaultColormap");
  defxforeign(ctx,"XDefaultColormapOfScreen");
  defxforeign(ctx,"XDefaultDepth");
  defxforeign(ctx,"XDefaultDepthOfScreen");
  defxforeign(ctx,"XDefaultGC");
  defxforeign(ctx,"XDefaultGCOfScreen");
  defxforeign(ctx,"XDefaultRootWindow");
  defxforeign(ctx,"XDefaultScreen");
  defxforeign(ctx,"XDefaultScreenOfDisplay");
  defxforeign(ctx,"XDefaultVisual");
  defxforeign(ctx,"XDefaultVisualOfScreen");
  defxforeign(ctx,"XDestroyImage");
  defxforeign(ctx,"XDisplayCells");
  defxforeign(ctx,"XDisplayHeight");
  defxforeign(ctx,"XDisplayHeightMM");
  defxforeign(ctx,"XDisplayOfScreen");
  defxforeign(ctx,"XDisplayPlanes");
  defxforeign(ctx,"XDisplayString");
  defxforeign(ctx,"XDisplayWidth");
  defxforeign(ctx,"XDisplayWidthMM");
  defxforeign(ctx,"XDoesBackingStore");
  defxforeign(ctx,"XDoesSaveUnders");
  defxforeign(ctx,"XEventMaskOfScreen");
  defxforeign(ctx,"XGetPixel");
  defxforeign(ctx,"XHeightMMOfScreen");
  defxforeign(ctx,"XHeightOfScreen");
  defxforeign(ctx,"XImageByteOrder");
  defxforeign(ctx,"XLastKnownRequestProcessed");
  defxforeign(ctx,"XMaxCmapsOfScreen");
  defxforeign(ctx,"XMinCmapsOfScreen");
  defxforeign(ctx,"XNextRequest");
  defxforeign(ctx,"XNoOp");
  defxforeign(ctx,"XPlanesOfScreen");
  defxforeign(ctx,"XProtocolRevision");
  defxforeign(ctx,"XProtocolVersion");
  defxforeign(ctx,"XPutPixel");
  defxforeign(ctx,"XQLength");
  defxforeign(ctx,"XRootWindow");
  defxforeign(ctx,"XRootWindowOfScreen");
  defxforeign(ctx,"XScreenCount");
  defxforeign(ctx,"XScreenOfDisplay");
  defxforeign(ctx,"XServerVendor");
  defxforeign(ctx,"XSubImage");
  defxforeign(ctx,"XVendorRelease");
  defxforeign(ctx,"XWhitePixel");
  defxforeign(ctx,"XWhitePixelOfScreen");
  defxforeign(ctx,"XWidthMMOfScreen");
  defxforeign(ctx,"XWidthOfScreen");
  defxforeign(ctx,"XMapRaised");
  defxforeign(ctx,"XMapSubwindows");
  defxforeign(ctx,"XMapWindow");
  defxforeign(ctx,"XMaskEvent");
  defxforeign(ctx,"XDeleteModifiermapEntry");
  defxforeign(ctx,"XFreeModifiermap");
  defxforeign(ctx,"XGetModifierMapping");
  defxforeign(ctx,"XInsertModifiermapEntry");
  defxforeign(ctx,"XNewModifiermap");
  defxforeign(ctx,"XSetModifierMapping");
  defxforeign(ctx,"XMoveWindow");
  defxforeign(ctx,"XNextEvent");
  defxforeign(ctx,"XOpenDisplay");
  defxforeign(ctx,"XParseColor");
/*   defxforeign(ctx,"ReadInteger"); */
  defxforeign(ctx,"XParseGeometry");
  defxforeign(ctx,"XPeekEvent");
  defxforeign(ctx,"XPeekIfEvent");
  defxforeign(ctx,"XEventsQueued");
  defxforeign(ctx,"XPending");
  defxforeign(ctx,"XSetWindowBackgroundPixmap");
  defxforeign(ctx,"XSetWindowBorderPixmap");
  defxforeign(ctx,"XPolygonRegion");
  defxforeign(ctx,"XDrawText");
  defxforeign(ctx,"XDrawText16");
  defxforeign(ctx,"XPutBackEvent");
  defxforeign(ctx,"XPutImage");
  defxforeign(ctx,"XQueryBestSize");
  defxforeign(ctx,"XQueryColor");
  defxforeign(ctx,"XQueryColors");
  defxforeign(ctx,"XQueryBestCursor");
  defxforeign(ctx,"XQueryExtension");
  defxforeign(ctx,"XQueryKeymap");
  defxforeign(ctx,"XQueryPointer");
  defxforeign(ctx,"XQueryBestStipple");
  defxforeign(ctx,"XQueryTextExtents16");
  defxforeign(ctx,"XQueryTextExtents");
  defxforeign(ctx,"XQueryBestTile");
  defxforeign(ctx,"XQueryTree");
  defxforeign(ctx,"XRaiseWindow");
  defxforeign(ctx,"XReadBitmapFile");
  defxforeign(ctx,"XRecolorCursor");
  defxforeign(ctx,"XConfigureWindow");
  defxforeign(ctx,"XClipBox");
  defxforeign(ctx,"XCreateRegion");
  defxforeign(ctx,"XDestroyRegion");
  defxforeign(ctx,"XEmptyRegion");
  defxforeign(ctx,"XEqualRegion");
  defxforeign(ctx,"XIntersectRegion");
  defxforeign(ctx,"XOffsetRegion");
  defxforeign(ctx,"XPointInRegion");
  defxforeign(ctx,"XRectInRegion");
  defxforeign(ctx,"XSetRegion");
  defxforeign(ctx,"XShrinkRegion");
  defxforeign(ctx,"XSubtractRegion");
  defxforeign(ctx,"XUnionRectWithRegion");
  defxforeign(ctx,"XUnionRegion");
  defxforeign(ctx,"XXorRegion");
/*   defxforeign(ctx,"combineRegs"); */
  defxforeign(ctx,"XReparentWindow");
  defxforeign(ctx,"XRestackWindows");
  defxforeign(ctx,"XRotateWindowProperties");
  defxforeign(ctx,"XSelectInput");
  defxforeign(ctx,"XSendEvent");
  defxforeign(ctx,"XSetBackground");
  defxforeign(ctx,"XSetClipRectangles");
  defxforeign(ctx,"XSetClipMask");
  defxforeign(ctx,"XSetClipOrigin");
  defxforeign(ctx,"XSetDashes");
  defxforeign(ctx,"XSetFontPath");
  defxforeign(ctx,"XSetFont");
  defxforeign(ctx,"XSetForeground");
  defxforeign(ctx,"XSetFunction");
  defxforeign(ctx,"XSetClassHint");
  defxforeign(ctx,"XSetCommand");
  defxforeign(ctx,"XSetIconSizes");
  defxforeign(ctx,"XSetNormalHints");
  defxforeign(ctx,"XSetSizeHints");
  defxforeign(ctx,"XSetStandardProperties");
  defxforeign(ctx,"XSetTransientForHint");
  defxforeign(ctx,"XSetWMHints");
  defxforeign(ctx,"XSetZoomHints");
  defxforeign(ctx,"XSetInputFocus");
  defxforeign(ctx,"XSetLineAttributes");
  defxforeign(ctx,"XSetPlaneMask");
  defxforeign(ctx,"XChangeKeyboardMapping");
  defxforeign(ctx,"XSetPointerMapping");
  defxforeign(ctx,"XSetSelectionOwner");
  defxforeign(ctx,"XSetScreenSaver");
  defxforeign(ctx,"XSetState");
  defxforeign(ctx,"XSetStipple");
  defxforeign(ctx,"XSetStandardColormap");
  defxforeign(ctx,"XSetTile");
  defxforeign(ctx,"XSetTSOrigin");
  defxforeign(ctx,"XFetchBuffer");
  defxforeign(ctx,"XFetchBytes");
  defxforeign(ctx,"XRotateBuffers");
  defxforeign(ctx,"XStoreBuffer");
  defxforeign(ctx,"XStoreBytes");
  defxforeign(ctx,"XStoreColor");
  defxforeign(ctx,"XStoreColors");
  defxforeign(ctx,"XStoreNamedColor");
  defxforeign(ctx,"XSetIconName");
  defxforeign(ctx,"XStoreName");
  defxforeign(ctx,"XKeysymToString");
  defxforeign(ctx,"XStringToKeysym");
  defxforeign(ctx,"XSync");
  defxforeign(ctx,"XSetAfterFunction");
  defxforeign(ctx,"XSynchronize");
  defxforeign(ctx,"XDrawString");
  defxforeign(ctx,"XDrawString16");
  defxforeign(ctx,"XTextExtents");
  defxforeign(ctx,"XTextWidth");
  defxforeign(ctx,"XTextExtents16");
  defxforeign(ctx,"XTextWidth16");
  defxforeign(ctx,"XTranslateCoordinates");
  defxforeign(ctx,"XUndefineCursor");
  defxforeign(ctx,"XUngrabButton");
  defxforeign(ctx,"XUngrabKeyboard");
  defxforeign(ctx,"XUngrabKey");
  defxforeign(ctx,"XUngrabPointer");
  defxforeign(ctx,"XUngrabServer");
  defxforeign(ctx,"XUninstallColormap");
  defxforeign(ctx,"XUnloadFont");
  defxforeign(ctx,"XUnmapSubwindows");
  defxforeign(ctx,"XUnmapWindow");
  defxforeign(ctx,"XGetVisualInfo");
  defxforeign(ctx,"XMatchVisualInfo");
  defxforeign(ctx,"XWarpPointer");
  defxforeign(ctx,"XWindowEvent");
  defxforeign(ctx,"XCreateWindow");
  defxforeign(ctx,"XWriteBitmapFile");
  defxforeign(ctx,"XFree");
  defxforeign(ctx,"XrmGetFileDatabase");
  defxforeign(ctx,"XrmGetResource");
  defxforeign(ctx,"XrmGetStringDatabase");
  defxforeign(ctx,"XrmInitialize");
  defxforeign(ctx,"XrmMergeDatabases");
  defxforeign(ctx,"XrmPutFileDatabase");
  defxforeign(ctx,"XrmPutLineResource");
  defxforeign(ctx,"XrmPutResource");
  defxforeign(ctx,"XrmPutStringResource");
  defxforeign(ctx,"XrmQGetResource");
  defxforeign(ctx,"XrmQGetSearchList");
  defxforeign(ctx,"XrmQGetSearchResource");
  defxforeign(ctx,"XrmQPutResource");
  defxforeign(ctx,"XrmQPutStringResource");
  defxforeign(ctx,"XrmStringToBindingQuarkList");
  defxforeign(ctx,"XrmStringToQuarkList");
#if X_V11R6_1
  defxforeign(ctx,"XInitThreads");
  defxforeign(ctx,"XLockDisplay");
  defxforeign(ctx,"XUnlockDisplay");
#endif
  return(argv[0]);
}

static void init_object_module()
  { add_module_initializer("xforeign", xforeign);}
