BSD 4_3_Tahoe development
authorCSRG <csrg@ucbvax.Berkeley.EDU>
Mon, 1 Dec 1986 09:09:18 +0000 (01:09 -0800)
committerCSRG <csrg@ucbvax.Berkeley.EDU>
Mon, 1 Dec 1986 09:09:18 +0000 (01:09 -0800)
Work on file usr/src/new/X/Xlib/XClrIconWind.c
Work on file usr/src/new/X/Xlib/XCompEvents.c
Work on file usr/src/new/X/Xlib/XConfWindow.c
Work on file usr/src/new/X/Xlib/XCopyArea.c
Work on file usr/src/new/X/Xlib/XCreatTranss.c
Work on file usr/src/new/X/Xlib/XCreate.c
Work on file usr/src/new/X/Xlib/XCreateCursor.c
Work on file usr/src/new/X/Xlib/XCreateTrans.c
Work on file usr/src/new/X/Xlib/XCreateWinBat.c
Work on file usr/src/new/X/Xlib/XCreateWindow.c
Work on file usr/src/new/X/Xlib/XCreateWinds.c
Work on file usr/src/new/X/Xlib/XDefineCursor.c
Work on file usr/src/new/X/Xlib/XDestSubWind.c
Work on file usr/src/new/X/Xlib/XDestWindow.c
Work on file usr/src/new/X/Xlib/XDisplayName.c
Work on file usr/src/new/X/Xlib/XDraw.c
Work on file usr/src/new/X/Xlib/XDrawDashed.c
Work on file usr/src/new/X/Xlib/XDrawFilled.c
Work on file usr/src/new/X/Xlib/XDrawPatternd.c
Work on file usr/src/new/X/Xlib/XDrawTiled.c
Work on file usr/src/new/X/Xlib/XErrDescrip.c
Work on file usr/src/new/X/Xlib/XErrHndlr.c
Work on file usr/src/new/X/Xlib/XExpandEvents.c
Work on file usr/src/new/X/Xlib/XFeep.c
Work on file usr/src/new/X/Xlib/XFeepControl.c
Work on file usr/src/new/X/Xlib/XFetchBuffer.c
Work on file usr/src/new/X/Xlib/XFetchBytes.c
Work on file usr/src/new/X/Xlib/XFetchName.c
Work on file usr/src/new/X/Xlib/XFlush.c
Work on file usr/src/new/X/Xlib/XFocusKbd.c
Work on file usr/src/new/X/Xlib/XFontWidths.c
Work on file usr/src/new/X/Xlib/XFreeBitmap.c
Work on file usr/src/new/X/Xlib/XFreeColors.c
Work on file usr/src/new/X/Xlib/XFreeCursor.c
Work on file usr/src/new/X/Xlib/XFreeFont.c
Work on file usr/src/new/X/Xlib/XFreePixmap.c
Work on file usr/src/new/X/Xlib/XGeom.c
Work on file usr/src/new/X/Xlib/XGetColCells.c
Work on file usr/src/new/X/Xlib/XGetColor.c
Work on file usr/src/new/X/Xlib/XGetDefault.c
Work on file usr/src/new/X/Xlib/XGetFont.c
Work on file usr/src/new/X/Xlib/XGetHardColor.c
Work on file usr/src/new/X/Xlib/XGetHosts.c
Work on file usr/src/new/X/Xlib/XGetIconWind.c
Work on file usr/src/new/X/Xlib/XGetNodes.c
Work on file usr/src/new/X/Xlib/XGetResHint.c
Work on file usr/src/new/X/doc/Usenix/Makefile
Work on file usr/src/new/X/Xlib/XGrabButton.c
Work on file usr/src/new/X/Xlib/XGrabMouse.c
Work on file usr/src/new/X/Xlib/XGrabServer.c
Work on file usr/src/new/X/Xlib/XIOErrHndlr.c
Work on file usr/src/new/X/Xlib/XInterpLoc.c
Work on file usr/src/new/X/Xlib/XKeyClickCon.c
Work on file usr/src/new/X/Xlib/XLine.c
Work on file usr/src/new/X/Xlib/XLockToggle.c
Work on file usr/src/new/X/Xlib/XLockUpDown.c
Work on file usr/src/new/X/Xlib/XLowerWindow.c
Work on file usr/src/new/X/Xlib/XMakePattern.c
Work on file usr/src/new/X/Xlib/XMakePixmap.c
Work on file usr/src/new/X/Xlib/XMakeTile.c
Work on file usr/src/new/X/Xlib/XMakeTiles.c
Work on file usr/src/new/X/Xlib/XMapSubWind.c
Work on file usr/src/new/X/Xlib/XMapWindow.c
Work on file usr/src/new/X/Xlib/XMaskEvent.c
Work on file usr/src/new/X/Xlib/XMouseControl.c
Work on file usr/src/new/X/Xlib/XMoveArea.c
Work on file usr/src/new/X/Xlib/XMoveWindow.c
Work on file usr/src/new/X/Xlib/XNextEvent.c
Work on file usr/src/new/X/Xlib/XOpenFont.c
Work on file usr/src/new/X/Xlib/XParseColor.c
Work on file usr/src/new/X/Xlib/XParseGeom.c
Work on file usr/src/new/X/Xlib/XPeekEvent.c
Work on file usr/src/new/X/Xlib/XPending.c
Work on file usr/src/new/X/Xlib/XPixBitsPutXY.c
Work on file usr/src/new/X/Xlib/XPixBitsPutZ.c
Work on file usr/src/new/X/Xlib/XPixFill.c
Work on file usr/src/new/X/Xlib/XPixSet.c
Work on file usr/src/new/X/Xlib/XPixmapGetXY.c
Work on file usr/src/new/X/Xlib/XPixmapGetZ.c
Work on file usr/src/new/X/Xlib/XPixmapPut.c
Work on file usr/src/new/X/Xlib/XPixmapSave.c
Work on file usr/src/new/X/Xlib/XPutBackEvent.c
Work on file usr/src/new/X/Xlib/XQueryBrush.c
Work on file usr/src/new/X/Xlib/XQueryButtons.c
Work on file usr/src/new/X/Xlib/XQueryColor.c
Work on file usr/src/new/X/Xlib/XQueryColors.c
Work on file usr/src/new/X/Xlib/XQueryCursor.c
Work on file usr/src/new/X/Xlib/XQueryFont.c
Work on file usr/src/new/X/Xlib/XQueryInput.c
Work on file usr/src/new/X/Xlib/XQueryMouse.c
Work on file usr/src/new/X/Xlib/XQueryTile.c
Work on file usr/src/new/X/Xlib/XQueryTree.c
Work on file usr/src/new/X/Xlib/XQueryWidth.c
Work on file usr/src/new/X/Xlib/XQueryWindow.c
Work on file usr/src/new/X/Xlib/XRaiseWindow.c
Work on file usr/src/new/X/Xlib/XReadBitmapF.c
Work on file usr/src/new/X/Xlib/XRemoveHost.c
Work on file usr/src/new/X/Xlib/XRemoveNode.c
Work on file usr/src/new/X/Xlib/XRotBuffers.c
Work on file usr/src/new/X/Xlib/XScreenSaver.c
Work on file usr/src/new/X/Xlib/XSelectInput.c
Work on file usr/src/new/X/Xlib/XSetDisplay.c
Work on file usr/src/new/X/Xlib/XSetIconWind.c
Work on file usr/src/new/X/Xlib/XSetResHint.c
Work on file usr/src/new/X/Xlib/XStippleFill.c
Work on file usr/src/new/X/Xlib/XStoreBitmap.c
Work on file usr/src/new/X/Xlib/XStoreBuffer.c
Work on file usr/src/new/X/Xlib/XStoreBytes.c
Work on file usr/src/new/X/Xlib/XStoreColor.c
Work on file usr/src/new/X/Xlib/XStoreColors.c
Work on file usr/src/new/X/Xlib/XStoreCursor.c
Work on file usr/src/new/X/Xlib/XStoreName.c
Work on file usr/src/new/X/Xlib/XStorePixXY.c
Work on file usr/src/new/X/Xlib/XStorePixmapZ.c
Work on file usr/src/new/X/Xlib/XStringWidth.c
Work on file usr/src/new/X/Xlib/XSync.c
Work on file usr/src/new/X/Xlib/XText.c
Work on file usr/src/new/X/Xlib/XTextMask.c
Work on file usr/src/new/X/Xlib/XTextMaskPad.c
Work on file usr/src/new/X/Xlib/XTextPad.c
Work on file usr/src/new/X/Xlib/XTileAbsolute.c
Work on file usr/src/new/X/Xlib/XTileFill.c
Work on file usr/src/new/X/Xlib/XTileRelative.c
Work on file usr/src/new/X/Xlib/XTileSet.c
Work on file usr/src/new/X/Xlib/XUndefCursor.c
Work on file usr/src/new/X/Xlib/XUngrabButton.c
Work on file usr/src/new/X/Xlib/XUngrabMouse.c
Work on file usr/src/new/X/Xlib/XUngrabServer.c
Work on file usr/src/new/X/Xlib/XUnmapSubs.c
Work on file usr/src/new/X/Xlib/XUnmapTrans.c
Work on file usr/src/new/X/Xlib/XUnmapWindow.c
Work on file usr/src/new/X/Xlib/XUpdateMouse.c
Work on file usr/src/new/X/Xlib/XWarpCond.c
Work on file usr/src/new/X/Xlib/XWarpMouse.c
Work on file usr/src/new/X/Xlib/XWindowEvent.c
Work on file usr/src/new/X/Xlib/Xdefault.h
Work on file usr/src/new/X/Xlib/Xkeyboard.h
Work on file usr/src/new/X/include/X/Xkeyboard.h
Work on file usr/src/new/X/Xlib/Xkeymap.h
Work on file usr/src/new/X/keycomp/Xkeymap.h
Work on file usr/src/new/X/Xlib/XlibInternal.c
Work on file usr/src/new/X/keycomp/Makefile
Work on file usr/src/new/X/keycomp/Xkeymap.default
Work on file usr/src/new/X/keycomp/keycomp.c
Work on file usr/src/new/X/Xlib/XlibInternal.h
Work on file usr/src/new/X/include/X/Xtext.h
Work on file usr/src/new/X/Xlib/Xtext.h
Work on file usr/src/new/X/Xlib/Xtextlib.c
Work on file usr/src/new/X/Xlib/Xtty.h
Work on file usr/src/new/X/include/X/Xtty.h
Work on file usr/src/new/X/Xlib/Xttylib.c
Work on file usr/src/new/X/Xlib/keymap.c

Synthesized-from: CSRG/cd2/4.3tahoe

152 files changed:
usr/src/new/X/Xlib/XClrIconWind.c [new file with mode: 0644]
usr/src/new/X/Xlib/XCompEvents.c [new file with mode: 0644]
usr/src/new/X/Xlib/XConfWindow.c [new file with mode: 0644]
usr/src/new/X/Xlib/XCopyArea.c [new file with mode: 0644]
usr/src/new/X/Xlib/XCreatTranss.c [new file with mode: 0644]
usr/src/new/X/Xlib/XCreate.c [new file with mode: 0644]
usr/src/new/X/Xlib/XCreateCursor.c [new file with mode: 0644]
usr/src/new/X/Xlib/XCreateTrans.c [new file with mode: 0644]
usr/src/new/X/Xlib/XCreateWinBat.c [new file with mode: 0644]
usr/src/new/X/Xlib/XCreateWindow.c [new file with mode: 0644]
usr/src/new/X/Xlib/XCreateWinds.c [new file with mode: 0644]
usr/src/new/X/Xlib/XDefineCursor.c [new file with mode: 0644]
usr/src/new/X/Xlib/XDestSubWind.c [new file with mode: 0644]
usr/src/new/X/Xlib/XDestWindow.c [new file with mode: 0644]
usr/src/new/X/Xlib/XDisplayName.c [new file with mode: 0644]
usr/src/new/X/Xlib/XDraw.c [new file with mode: 0644]
usr/src/new/X/Xlib/XDrawDashed.c [new file with mode: 0644]
usr/src/new/X/Xlib/XDrawFilled.c [new file with mode: 0644]
usr/src/new/X/Xlib/XDrawPatternd.c [new file with mode: 0644]
usr/src/new/X/Xlib/XDrawTiled.c [new file with mode: 0644]
usr/src/new/X/Xlib/XErrDescrip.c [new file with mode: 0644]
usr/src/new/X/Xlib/XErrHndlr.c [new file with mode: 0644]
usr/src/new/X/Xlib/XExpandEvents.c [new file with mode: 0644]
usr/src/new/X/Xlib/XFeep.c [new file with mode: 0644]
usr/src/new/X/Xlib/XFeepControl.c [new file with mode: 0644]
usr/src/new/X/Xlib/XFetchBuffer.c [new file with mode: 0644]
usr/src/new/X/Xlib/XFetchBytes.c [new file with mode: 0644]
usr/src/new/X/Xlib/XFetchName.c [new file with mode: 0644]
usr/src/new/X/Xlib/XFlush.c [new file with mode: 0644]
usr/src/new/X/Xlib/XFocusKbd.c [new file with mode: 0644]
usr/src/new/X/Xlib/XFontWidths.c [new file with mode: 0644]
usr/src/new/X/Xlib/XFreeBitmap.c [new file with mode: 0644]
usr/src/new/X/Xlib/XFreeColors.c [new file with mode: 0644]
usr/src/new/X/Xlib/XFreeCursor.c [new file with mode: 0644]
usr/src/new/X/Xlib/XFreeFont.c [new file with mode: 0644]
usr/src/new/X/Xlib/XFreePixmap.c [new file with mode: 0644]
usr/src/new/X/Xlib/XGeom.c [new file with mode: 0644]
usr/src/new/X/Xlib/XGetColCells.c [new file with mode: 0644]
usr/src/new/X/Xlib/XGetColor.c [new file with mode: 0644]
usr/src/new/X/Xlib/XGetDefault.c [new file with mode: 0644]
usr/src/new/X/Xlib/XGetFont.c [new file with mode: 0644]
usr/src/new/X/Xlib/XGetHardColor.c [new file with mode: 0644]
usr/src/new/X/Xlib/XGetHosts.c [new file with mode: 0644]
usr/src/new/X/Xlib/XGetIconWind.c [new file with mode: 0644]
usr/src/new/X/Xlib/XGetNodes.c [new file with mode: 0644]
usr/src/new/X/Xlib/XGetResHint.c [new file with mode: 0644]
usr/src/new/X/Xlib/XGrabButton.c [new file with mode: 0644]
usr/src/new/X/Xlib/XGrabMouse.c [new file with mode: 0644]
usr/src/new/X/Xlib/XGrabServer.c [new file with mode: 0644]
usr/src/new/X/Xlib/XIOErrHndlr.c [new file with mode: 0644]
usr/src/new/X/Xlib/XInterpLoc.c [new file with mode: 0644]
usr/src/new/X/Xlib/XKeyClickCon.c [new file with mode: 0644]
usr/src/new/X/Xlib/XLine.c [new file with mode: 0644]
usr/src/new/X/Xlib/XLockToggle.c [new file with mode: 0644]
usr/src/new/X/Xlib/XLockUpDown.c [new file with mode: 0644]
usr/src/new/X/Xlib/XLowerWindow.c [new file with mode: 0644]
usr/src/new/X/Xlib/XMakePattern.c [new file with mode: 0644]
usr/src/new/X/Xlib/XMakePixmap.c [new file with mode: 0644]
usr/src/new/X/Xlib/XMakeTile.c [new file with mode: 0644]
usr/src/new/X/Xlib/XMakeTiles.c [new file with mode: 0644]
usr/src/new/X/Xlib/XMapSubWind.c [new file with mode: 0644]
usr/src/new/X/Xlib/XMapWindow.c [new file with mode: 0644]
usr/src/new/X/Xlib/XMaskEvent.c [new file with mode: 0644]
usr/src/new/X/Xlib/XMouseControl.c [new file with mode: 0644]
usr/src/new/X/Xlib/XMoveArea.c [new file with mode: 0644]
usr/src/new/X/Xlib/XMoveWindow.c [new file with mode: 0644]
usr/src/new/X/Xlib/XNextEvent.c [new file with mode: 0644]
usr/src/new/X/Xlib/XOpenFont.c [new file with mode: 0644]
usr/src/new/X/Xlib/XParseColor.c [new file with mode: 0644]
usr/src/new/X/Xlib/XParseGeom.c [new file with mode: 0644]
usr/src/new/X/Xlib/XPeekEvent.c [new file with mode: 0644]
usr/src/new/X/Xlib/XPending.c [new file with mode: 0644]
usr/src/new/X/Xlib/XPixBitsPutXY.c [new file with mode: 0644]
usr/src/new/X/Xlib/XPixBitsPutZ.c [new file with mode: 0644]
usr/src/new/X/Xlib/XPixFill.c [new file with mode: 0644]
usr/src/new/X/Xlib/XPixSet.c [new file with mode: 0644]
usr/src/new/X/Xlib/XPixmapGetXY.c [new file with mode: 0644]
usr/src/new/X/Xlib/XPixmapGetZ.c [new file with mode: 0644]
usr/src/new/X/Xlib/XPixmapPut.c [new file with mode: 0644]
usr/src/new/X/Xlib/XPixmapSave.c [new file with mode: 0644]
usr/src/new/X/Xlib/XPutBackEvent.c [new file with mode: 0644]
usr/src/new/X/Xlib/XQueryBrush.c [new file with mode: 0644]
usr/src/new/X/Xlib/XQueryButtons.c [new file with mode: 0644]
usr/src/new/X/Xlib/XQueryColor.c [new file with mode: 0644]
usr/src/new/X/Xlib/XQueryColors.c [new file with mode: 0644]
usr/src/new/X/Xlib/XQueryCursor.c [new file with mode: 0644]
usr/src/new/X/Xlib/XQueryFont.c [new file with mode: 0644]
usr/src/new/X/Xlib/XQueryInput.c [new file with mode: 0644]
usr/src/new/X/Xlib/XQueryMouse.c [new file with mode: 0644]
usr/src/new/X/Xlib/XQueryTile.c [new file with mode: 0644]
usr/src/new/X/Xlib/XQueryTree.c [new file with mode: 0644]
usr/src/new/X/Xlib/XQueryWidth.c [new file with mode: 0644]
usr/src/new/X/Xlib/XQueryWindow.c [new file with mode: 0644]
usr/src/new/X/Xlib/XRaiseWindow.c [new file with mode: 0644]
usr/src/new/X/Xlib/XReadBitmapF.c [new file with mode: 0644]
usr/src/new/X/Xlib/XRemoveHost.c [new file with mode: 0644]
usr/src/new/X/Xlib/XRemoveNode.c [new file with mode: 0644]
usr/src/new/X/Xlib/XRotBuffers.c [new file with mode: 0644]
usr/src/new/X/Xlib/XScreenSaver.c [new file with mode: 0644]
usr/src/new/X/Xlib/XSelectInput.c [new file with mode: 0644]
usr/src/new/X/Xlib/XSetDisplay.c [new file with mode: 0644]
usr/src/new/X/Xlib/XSetIconWind.c [new file with mode: 0644]
usr/src/new/X/Xlib/XSetResHint.c [new file with mode: 0644]
usr/src/new/X/Xlib/XStippleFill.c [new file with mode: 0644]
usr/src/new/X/Xlib/XStoreBitmap.c [new file with mode: 0644]
usr/src/new/X/Xlib/XStoreBuffer.c [new file with mode: 0644]
usr/src/new/X/Xlib/XStoreBytes.c [new file with mode: 0644]
usr/src/new/X/Xlib/XStoreColor.c [new file with mode: 0644]
usr/src/new/X/Xlib/XStoreColors.c [new file with mode: 0644]
usr/src/new/X/Xlib/XStoreCursor.c [new file with mode: 0644]
usr/src/new/X/Xlib/XStoreName.c [new file with mode: 0644]
usr/src/new/X/Xlib/XStorePixXY.c [new file with mode: 0644]
usr/src/new/X/Xlib/XStorePixmapZ.c [new file with mode: 0644]
usr/src/new/X/Xlib/XStringWidth.c [new file with mode: 0644]
usr/src/new/X/Xlib/XSync.c [new file with mode: 0644]
usr/src/new/X/Xlib/XText.c [new file with mode: 0644]
usr/src/new/X/Xlib/XTextMask.c [new file with mode: 0644]
usr/src/new/X/Xlib/XTextMaskPad.c [new file with mode: 0644]
usr/src/new/X/Xlib/XTextPad.c [new file with mode: 0644]
usr/src/new/X/Xlib/XTileAbsolute.c [new file with mode: 0644]
usr/src/new/X/Xlib/XTileFill.c [new file with mode: 0644]
usr/src/new/X/Xlib/XTileRelative.c [new file with mode: 0644]
usr/src/new/X/Xlib/XTileSet.c [new file with mode: 0644]
usr/src/new/X/Xlib/XUndefCursor.c [new file with mode: 0644]
usr/src/new/X/Xlib/XUngrabButton.c [new file with mode: 0644]
usr/src/new/X/Xlib/XUngrabMouse.c [new file with mode: 0644]
usr/src/new/X/Xlib/XUngrabServer.c [new file with mode: 0644]
usr/src/new/X/Xlib/XUnmapSubs.c [new file with mode: 0644]
usr/src/new/X/Xlib/XUnmapTrans.c [new file with mode: 0644]
usr/src/new/X/Xlib/XUnmapWindow.c [new file with mode: 0644]
usr/src/new/X/Xlib/XUpdateMouse.c [new file with mode: 0644]
usr/src/new/X/Xlib/XWarpCond.c [new file with mode: 0644]
usr/src/new/X/Xlib/XWarpMouse.c [new file with mode: 0644]
usr/src/new/X/Xlib/XWindowEvent.c [new file with mode: 0644]
usr/src/new/X/Xlib/Xdefault.h [new file with mode: 0644]
usr/src/new/X/Xlib/Xkeyboard.h [new file with mode: 0644]
usr/src/new/X/Xlib/Xkeymap.h [new file with mode: 0644]
usr/src/new/X/Xlib/XlibInternal.c [new file with mode: 0644]
usr/src/new/X/Xlib/XlibInternal.h [new file with mode: 0644]
usr/src/new/X/Xlib/Xtext.h [new file with mode: 0644]
usr/src/new/X/Xlib/Xtextlib.c [new file with mode: 0644]
usr/src/new/X/Xlib/Xtty.h [new file with mode: 0644]
usr/src/new/X/Xlib/Xttylib.c [new file with mode: 0644]
usr/src/new/X/Xlib/keymap.c [new file with mode: 0644]
usr/src/new/X/doc/Usenix/Makefile [new file with mode: 0644]
usr/src/new/X/include/X/Xkeyboard.h [new symlink]
usr/src/new/X/include/X/Xtext.h [new symlink]
usr/src/new/X/include/X/Xtty.h [new symlink]
usr/src/new/X/keycomp/Makefile [new file with mode: 0644]
usr/src/new/X/keycomp/Xkeymap.default [new file with mode: 0644]
usr/src/new/X/keycomp/Xkeymap.h [new symlink]
usr/src/new/X/keycomp/keycomp.c [new file with mode: 0644]

diff --git a/usr/src/new/X/Xlib/XClrIconWind.c b/usr/src/new/X/Xlib/XClrIconWind.c
new file mode 100644 (file)
index 0000000..3b25280
--- /dev/null
@@ -0,0 +1,16 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XClrIconWind.c,v 10.4 86/02/01 15:30:39 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XClearIconWindow (w)
+       Window w;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_SetIconWindow, w);
+       req->param.l[0] = 0;
+}
+
diff --git a/usr/src/new/X/Xlib/XCompEvents.c b/usr/src/new/X/Xlib/XCompEvents.c
new file mode 100644 (file)
index 0000000..f653752
--- /dev/null
@@ -0,0 +1,17 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XCompEvents.c,v 10.4 86/02/01 15:30:42 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+
+/*
+ * XCompressEvents - Compress MouseMoved events such that only the last
+ * contiguous MouseMoved event is returned.
+ */
+XCompressEvents()
+{
+       _XlibCurrentDisplay->squish = 1;
+}
+
diff --git a/usr/src/new/X/Xlib/XConfWindow.c b/usr/src/new/X/Xlib/XConfWindow.c
new file mode 100644 (file)
index 0000000..f4207f2
--- /dev/null
@@ -0,0 +1,21 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XConfWindow.c,v 10.5 86/04/22 15:24:00 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XConfigureWindow (w, x, y, width, height)
+       Window w;
+       int x, y, width, height;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_ConfigureWindow, w);
+       req->func = 0;  /* "for future expansion", sez X.doc */
+       req->params0 = height;
+       req->params1 = width;
+       req->params2 = x;
+       req->params3 = y;
+}
+
diff --git a/usr/src/new/X/Xlib/XCopyArea.c b/usr/src/new/X/Xlib/XCopyArea.c
new file mode 100644 (file)
index 0000000..539c4a7
--- /dev/null
@@ -0,0 +1,26 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XCopyArea.c,v 10.5 86/04/22 15:24:41 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XCopyArea (w, srcX, srcY, dstX, dstY, width, height, func, planes)
+       Window w;
+       int func;
+       int srcX, srcY, dstX, dstY, width, height;
+       int planes;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_CopyArea, w);
+       req->func = func;
+       req->mask = planes;
+       req->params0 = height;
+       req->params1 = width;
+       req->params2 = srcX;
+       req->params3 = srcY;
+       req->params6 = dstX;
+       req->params7 = dstY;
+}
+
diff --git a/usr/src/new/X/Xlib/XCreatTranss.c b/usr/src/new/X/Xlib/XCreatTranss.c
new file mode 100644 (file)
index 0000000..c6306a4
--- /dev/null
@@ -0,0 +1,45 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XCreatTranss.c,v 10.5 86/04/22 15:25:25 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+int XCreateTransparencies (parent, defs, ndefs)
+       Window parent;
+       TransparentFrame defs[];
+       int ndefs;
+{
+       register Display *dpy;
+       register int i;
+       register TransparentFrame *frame = defs;
+       int nresult = 0;
+
+       for (i=0;i<ndefs;i++) {
+           register XReq *req;
+           GetReq(X_CreateTransparency, parent);
+           req->params0 = frame->height;
+           req->params1 = frame->width;
+           req->params2 = frame->x;
+           req->params3 = (frame++)->y;
+           }
+
+       /* Reset request number to its old value, so that
+           error packets are processed correctly.  */
+       dpy->request -= ndefs;
+
+       frame = defs;
+       for (i=0;i<ndefs;i++) {
+           XRep rep;
+           /* Increment request number so error packets
+              are processed correctly. */
+           dpy->request++;
+           if (!_XReply(dpy, &rep))
+               (frame++)->self = NULL;
+           else {
+               (frame++)->self = rep.param.l[0];
+               nresult++;
+               }
+           }
+       return (nresult);
+}
+
diff --git a/usr/src/new/X/Xlib/XCreate.c b/usr/src/new/X/Xlib/XCreate.c
new file mode 100644 (file)
index 0000000..153229f
--- /dev/null
@@ -0,0 +1,428 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XCreate.c,v 10.10 86/08/11 12:55:45 wesommer Rel $ */
+/* Copyright 1985, Massachusetts Institute of Technology */
+/* stolen from CLU routine x_cons, redone by J. Gettys */
+
+#include "XlibInternal.h"
+#include <stdio.h>
+#define TRUE  1
+#define FALSE 0
+#define max(a,b) ( (a) > (b) ? (a) : (b) )
+#define min(a,b) ( (a) > (b) ? (b) : (a) )
+#define abs(a) ( (a) > 0 ? (a) : -(a))
+
+#define DCOUNT 2
+#define VCOUNT 1 + (4  * 2 * DCOUNT)
+#define FCOUNT 1 + 4
+
+#define CURSOR_LL 0
+#include "../cursors/ll_angle.cursor"
+#include "../cursors/ll_angle_mask.cursor"
+#define CURSOR_LR 1
+#include "../cursors/lr_angle.cursor"
+#include "../cursors/lr_angle_mask.cursor"
+#define CURSOR_UL 2
+#include "../cursors/ul_angle.cursor"
+#include "../cursors/ul_angle_mask.cursor"
+#define CURSOR_UR 3
+#include "../cursors/ur_angle.cursor"
+#include "../cursors/ur_angle_mask.cursor"
+
+
+Window XCreate(prompt, name, geometry, def, frame, minwidth, minheight)
+       char *prompt, *name;
+       register OpaqueFrame *frame;
+       int minwidth, minheight;
+       char *geometry, *def;
+       {
+       char *fn = "8x13";              /* default default font */
+       FontInfo *pfninfo;              /* font info on prompt */
+       Window pop;                     /* pop up window */
+       char *opt;
+       int pfore, pback;               /* prompt window colors */
+       int bpix;                       /* border color */
+       int mfore, mback;               /* mouse colors */
+       int pbw = 1;                    /* prompt window border width */
+       int ibw = 1;                    /* internal border width */
+       int freeze = 0;                 /* should we freeze the server */
+       Color cdef;                     /* color structure for lookup */
+       Cursor ur,ul,lr,ll;             /* cursors for rubber banding    */
+       int events;                     /* event mask */
+       int popw, poph;                 /* prompt window height and width */
+       int count = VCOUNT;             /* vertex count */
+       Pixmap save = 0;                /* saved pixmap */
+       Pixmap backmap, bdrmap;         /* background and border pixmaps */
+       Vertex box[VCOUNT];             /* vertex list for box */
+       int x1, y1;                     /* location of mouse */
+       int x2, y2;                     /* other corner of box */
+       Window subw;                    /* subwindow it is in */
+       int mindim;                     /* minimum dimension */
+       int width, height;              /* width and height of box */
+       int left, stop;
+       int mouse;
+       int force;                      /* force default window to track */
+       int xa, ya, xb, yb;
+       int doit;
+       XButtonEvent event;             /* someplace to put the event */
+       register int i;                 /* ye olde indexe variabel */
+       int fx, fy, fw, fh;             /* frame from parse... */
+       int pr;                         /* parse geometry result */
+       int change_cursor = FALSE;
+       int current_cursor = CURSOR_UL;
+
+       int HereButton = LeftButton;    /* make window at locator */
+       int ResizeButton = MiddleButton;/* make window of specified size */
+       int DefaultButton = RightButton;/* make window at default location */
+
+       pr = XGeometry (geometry, def, frame->bdrwidth, 1, 1, 0, 0,
+               &fx, &fy, &fw, &fh);
+       /*
+        * none of this nonsense would be necessary if I hadn't blown
+        * the frame structure definition.
+        */
+       frame->x = fx;
+       frame->y = fy;
+       frame->width = fw;
+       frame->height = fh;
+       if (geometry != NULL) {
+               /*
+                * if x or y offsets are specified, then we should autoplace
+                */
+               if ( (pr & XValue ) || (pr & YValue) ) {
+                   if (frame->width < minwidth) frame->width = minwidth;
+                   if (frame->height < minheight) frame->height = minheight;
+                   goto makeit;
+               }
+       }
+
+       if ((opt = XGetDefault(name, "MakeWindow.BodyFont")) != NULL) fn = opt;
+
+       if ((pfninfo = XOpenFont(fn)) == NULL) {
+               fprintf(stderr, "Can't open font %s!\n", fn);
+               return(0);
+               }
+
+       pfore = mback = WhitePixel;
+       pback = bpix = mfore = BlackPixel;
+       if ((opt = XGetDefault(name, "MakeWindow.ReverseVideo")) != NULL)
+               if (strcmp (opt, "on") == 0) {
+                       pfore = BlackPixel;
+                       pback = WhitePixel;
+                       }
+
+       if ((opt = XGetDefault(name, "MakeWindow.BorderWidth")) != NULL)
+               pbw = atoi (opt);
+
+       if ((opt = XGetDefault(name, "MakeWindow.InternalBorder")) != NULL)
+               ibw = atoi (opt);
+
+       if ((opt = XGetDefault(name, "MakeWindow.Freeze")) != NULL)
+               if (strcmp (opt, "on") == 0) freeze = 1;
+
+       if (DisplayPlanes() > 2) { /* on color display, do color stuff */
+       
+               if ((opt = XGetDefault(name,"MakeWindow.Foreground")) != NULL)
+                   if (XParseColor(opt, &cdef) && XGetHardwareColor(&cdef))
+                       pfore = cdef.pixel;
+
+               if ((opt = XGetDefault(name,"MakeWindow.Background")) != NULL)
+                   if (XParseColor(opt, &cdef) && XGetHardwareColor(&cdef))
+                       pback = cdef.pixel;
+
+               if ((opt = XGetDefault(name,"MakeWindow.Border")) != NULL)
+                   if (XParseColor(opt, &cdef) && XGetHardwareColor(&cdef))
+                       bpix = cdef.pixel;
+
+               if ((opt = XGetDefault(name,"MakeWindow.Mouse")) != NULL)
+                   if (XParseColor(opt, &cdef) && XGetHardwareColor(&cdef))
+                       mfore = cdef.pixel;
+
+               if ((opt = XGetDefault(name,"MakeWindow.MouseMask")) != NULL)
+                   if (XParseColor(opt, &cdef) && XGetHardwareColor(&cdef))
+                       mback = cdef.pixel;
+
+                       }
+
+       if ((opt = XGetDefault(name, "MakeWindow.Here")) != NULL) {
+               switch (*opt) {
+               case 'L':
+               case 'l':
+                       HereButton = LeftButton;
+                       break;
+
+               case 'M':
+               case 'm':
+                       HereButton = MiddleButton;
+                       break;
+
+               case 'R':
+               case 'r':
+                       HereButton = RightButton;
+                       break;
+               /*
+                * Should have a default case, to check for invalid
+                * specification, but what should be done in that case?
+                */
+               }
+       }
+
+       if ((opt = XGetDefault(name, "MakeWindow.Resize")) != NULL) {
+               switch (*opt) {
+               case 'L':
+               case 'l':
+                       ResizeButton = LeftButton;
+                       break;
+
+               case 'M':
+               case 'm':
+                       ResizeButton = MiddleButton;
+                       break;
+
+               case 'R':
+               case 'r':
+                       ResizeButton = RightButton;
+                       break;
+               /*
+                * Should have a default case, to check for invalid
+                * specification, but what should be done in that case?
+                */
+               }
+       }
+
+       if ((opt = XGetDefault(name, "MakeWindow.Default")) != NULL) {
+               switch (*opt) {
+               case 'L':
+               case 'l':
+                       DefaultButton = LeftButton;
+                       break;
+
+               case 'M':
+               case 'm':
+                       DefaultButton = MiddleButton;
+                       break;
+
+               case 'R':
+               case 'r':
+                       DefaultButton = RightButton;
+                       break;
+               /*
+                * Should have a default case, to check for invalid
+                * specification, but what should be done in that case?
+                */
+               }
+       }
+
+       /*
+        * Should verify that HereButton != ResizeButton != DefaultButton,
+        * but what should be done if that's false?
+        */
+
+       ur = XCreateCursor (ur_angle_width, ur_angle_height, ur_angle_bits, 
+               ur_angle_mask_bits, ur_angle_x_hot, ur_angle_y_hot,
+               mfore, mback, GXcopy);
+       ul = XCreateCursor (ul_angle_width, ul_angle_height, ul_angle_bits, 
+               ul_angle_mask_bits, ul_angle_x_hot, ul_angle_y_hot,
+               mfore, mback, GXcopy);
+       ll = XCreateCursor (ll_angle_width, ll_angle_height, ll_angle_bits, 
+               ll_angle_mask_bits, ll_angle_x_hot, ll_angle_y_hot,
+               mfore, mback, GXcopy);
+       lr = XCreateCursor (lr_angle_width, lr_angle_height, lr_angle_bits, 
+               lr_angle_mask_bits, lr_angle_x_hot, lr_angle_y_hot,
+               mfore, mback, GXcopy);
+
+       events = ButtonPressed | ButtonReleased;
+
+       if (freeze) events |= MouseMoved;
+
+       /* 
+        * go get the mouse as soon as you can 
+        */
+
+       while (1) {
+               if (XGrabMouse ( RootWindow, ul, events ) != 0) break;
+               sleep (1);
+               }
+       popw = XStringWidth (prompt, pfninfo, 0, 0) + 2 * ibw;
+       poph = pfninfo->height + 2 * ibw;
+
+       if (freeze) {
+               XGrabServer();
+               count = FCOUNT;
+               save = XPixmapSave (RootWindow, 0, 0, 
+                       popw + 2 * pbw, poph +2 * pbw);
+               }
+
+       backmap = XMakeTile (pback);
+       bdrmap = XMakeTile (bpix);
+
+       pop = XCreateWindow (RootWindow, 
+               0, 0, popw, poph, pbw, bdrmap, backmap);
+       XMapWindow( pop);
+       XText (pop, ibw, ibw, prompt, strlen(prompt), 
+               pfninfo->id, pfore, pback);
+
+       XQueryMouse (RootWindow, &x1, &y1, &subw);
+
+       mindim = 2 * frame->bdrwidth - 1;
+       minwidth  = minwidth  + mindim;
+       minheight = minheight + mindim;
+
+       x2 = x1 + minwidth;
+       y2 = y1 + minheight;
+
+       width  = minwidth;
+       height = minheight;
+
+       left = TRUE;
+       force = FALSE;
+       stop = FALSE;
+       mouse = TRUE;
+
+       xa = ya = xb = yb = -1;
+
+       doit = TRUE;
+
+       while (stop == FALSE) {
+           if (  (xb != max (x1, x2)) || (yb != max(y1, y2))
+               ||(xa != min (x1, x2)) || (ya != min(y1, y2))) {
+               if (freeze && (doit == FALSE)) {
+                       XDraw (RootWindow, box, count, 1, 1, 0, GXinvert, 1);
+                       }
+               xa = min (x1, x2);
+               ya = min (y1, y2);
+               xb = max (x1, x2);
+               yb = max (y1, y2);
+               for ( i = 0; i < count; i += 4) {
+                   box[i].x = xa; box[i].y = ya; box[i].flags = 0;
+                   if (i+1 == count) break;
+                   box[i+1].x = xb; box[i+1].y = ya, box[i+1].flags = 0;
+                   box[i+2].x = xb; box[i+2].y = yb, box[i+2].flags = 0;
+                   box[i+3].x = xa; box[i+3].y = yb, box[i+3].flags = 0;
+                   }
+               doit = TRUE;
+               }
+           if (doit) {
+               XDraw(RootWindow, box, count, 1, 1, 0, GXinvert, 1);
+               doit = !freeze;
+               }
+           if (freeze || XPending() ) {
+               register int button;
+               XNextEvent(&event);
+               button = event.detail & ValueMask;
+               if (mouse) {
+                       x2 = event.x;
+                       y2 = event.y;
+                       }
+               if ( (left == TRUE) && ( event.type == ButtonPressed ) && 
+                       ( button == ResizeButton ) ) {
+                       x1 = x2;
+                       y1 = y2;
+                       left = FALSE;
+                       change_cursor = TRUE;
+                       }
+               else if ( (left == FALSE) && (event.type == ButtonReleased) &&
+                       ( button == ResizeButton))
+                                       stop = TRUE;
+               else if ( (left == TRUE) && (event.type == ButtonPressed) &&
+                       ( button == DefaultButton)) {
+                       x1 = frame->x;
+                       y1 = frame->y;
+                       x2 = x1 + frame->width + mindim;
+                       y2 = y1 + frame->height + mindim;
+                       mouse = FALSE;
+                       left = FALSE;
+                       }
+               else if ( (left == FALSE) && (event.type == ButtonReleased) &&
+                       ( button == DefaultButton)) {
+                       x1 = frame->x;
+                       y1 = frame->y;
+                       x2 = x1 + frame->width + mindim;
+                       y2 = y1 + frame->height + mindim;
+                       stop = TRUE;
+                       }
+               else if ( (left == TRUE) && (event.type == ButtonPressed) &&
+                       ( button == HereButton)) {
+                       force = TRUE;
+                       left = FALSE;
+                       }
+               else if ( (left == FALSE) && (event.type == ButtonReleased) &&
+                       ( button == HereButton)) {
+                       stop = TRUE;
+                       }
+               else if (mouse) XQueryMouse (RootWindow, &x2, &y2, &subw);
+               }
+           else if (mouse) XQueryMouse (RootWindow, &x2, &y2, &subw);
+           if (change_cursor) {
+               if ((x2 >= x1) && (y2 >= y1) &&
+                   current_cursor != CURSOR_LR) {
+                   XGrabMouse ( RootWindow, lr, events );
+                   current_cursor = CURSOR_LR;
+               }
+               else if ((x2 >= x1) && (y2 < y1) &&
+                        current_cursor != CURSOR_UR) {
+                   XGrabMouse ( RootWindow, ur, events);
+                   current_cursor = CURSOR_UR;
+               }
+               else if ((x2 < x1) && (y2 >= y1) &&
+                        current_cursor != CURSOR_LL) {
+                   XGrabMouse ( RootWindow, ll, events);
+                   current_cursor = CURSOR_LL;
+               }
+               else if ((x2 < x1) && (y2 < y1) &&
+                        (current_cursor != CURSOR_UL)) {
+                   XGrabMouse ( RootWindow, ul, events);
+                   current_cursor = CURSOR_UL;
+               }
+           }
+           if (force) {        /* we force the default box */
+               x1 = x2;
+               y1 = y2;
+               x2 = x1 + frame->width + mindim;
+               y2 = y1 + frame->height + mindim;
+               }
+
+           if (left) {
+               x1 = x2;
+               y1 = y2;
+               }
+           width = max (abs (x2 - x1), minwidth);
+
+           if (x2 < x1) x2 = x1 - width;
+           else         x2 = x1 + width;
+
+           height = max (abs (y2 - y1), minheight);
+           if (y2 < y1) y2 = y1 - height;
+           else         y2 = y1 + height;
+       }
+       if (freeze) XDraw (RootWindow, box, count, 1, 1, 0, GXinvert, 1);
+       XUngrabMouse();
+
+       if (save != 0) {
+               XUnmapTransparent (pop);
+               XPixmapPut (RootWindow, 0, 0, 0, 0,
+                       popw + 2 * pbw, poph + 2 * pbw,
+                       save, GXcopy, AllPlanes);
+               XFreePixmap (save);
+               }
+       XDestroyWindow (pop);
+       if (freeze) XUngrabServer();
+       XCloseFont (pfninfo);
+       XFreeCursor (ur);
+       XFreeCursor (ul);
+       XFreeCursor (lr);
+       XFreeCursor (ll);
+       XFreePixmap (backmap);
+       XFreePixmap (bdrmap);
+       frame->x = min(x1, x2);
+       frame->y = min(y1, y2);
+       frame->width = width - mindim;
+       frame->height = height - mindim;
+makeit:        XCreateWindows(RootWindow, frame, 1);
+       /* store default name of the window and set the resize hint */
+       XStoreName(frame->self, prompt);
+       XSetResizeHint(frame->self, minwidth, minheight, 1, 1);
+       XSync(1);               /* get rid of any extraneous events */
+       return (frame->self);
+       }
+
diff --git a/usr/src/new/X/Xlib/XCreateCursor.c b/usr/src/new/X/Xlib/XCreateCursor.c
new file mode 100644 (file)
index 0000000..c3059eb
--- /dev/null
@@ -0,0 +1,65 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XCreateCursor.c,v 10.6 86/04/22 15:27:51 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+Cursor XCreateCursor (width, height, cursor, mask, xOffset, yOffset,
+    foreground, background, func)
+       short *cursor, *mask;
+       int width, height;
+       int xOffset, yOffset;
+       int func;
+       int foreground, background;
+{
+       register Display *dpy;
+       register XReq *req;
+       XRep rep;
+       Bitmap cbitmap, mbitmap = 0;
+       int nbytes = BitmapSize (width, height)/UBPS;
+       Status status;
+
+       GetReq(X_StoreBitmap, 0);
+       req->params0 = height;
+       req->params1 = width;
+       PackData (dpy, cursor, nbytes);
+
+       if (mask) {
+           GetReq(X_StoreBitmap, 0);
+           req->params0 = height;
+           req->params1 = width;
+           PackData (dpy, mask, nbytes);
+           dpy->request--; /* to synchronize properly with XError packets */
+           }
+
+       cbitmap = _XReply (dpy, &rep) ? rep.param.l[0] : 0;
+
+       if (mask) {
+           dpy->request++;
+           mbitmap = _XReply (dpy, &rep) ? rep.param.l[0] : 0;
+           }
+
+       if (!cbitmap || (mask && !mbitmap)) {
+           /* an error occurred. Clean up and return. */
+           if (cbitmap)
+               XFreeBitmap (cbitmap);
+           if (mbitmap)
+               XFreeBitmap (mbitmap);
+           return (0);
+           }
+
+       GetReq(X_StoreCursor, 0);
+       req->func = func;
+       req->param.l[0] = cbitmap;
+       req->params2 = foreground;
+       req->params3 = background;
+       req->param.l[2] = mbitmap;
+       req->params6 = xOffset;
+       req->params7 = yOffset;
+       status = _XReply (dpy, &rep);
+       XFreeBitmap (cbitmap);
+       if (mbitmap) 
+           XFreeBitmap (mbitmap);
+       return (status ? rep.param.l[0] : 0);
+}
+
diff --git a/usr/src/new/X/Xlib/XCreateTrans.c b/usr/src/new/X/Xlib/XCreateTrans.c
new file mode 100644 (file)
index 0000000..8ab089d
--- /dev/null
@@ -0,0 +1,24 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XCreateTrans.c,v 10.5 86/04/22 15:25:31 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+Window XCreateTransparency (parent, x, y, width, height)
+       int x, y, width, height;
+       Window parent;
+{
+       register Display *dpy;
+       register XReq *req;
+       XRep rep;
+
+       GetReq(X_CreateTransparency, parent);
+       req->params0 = height;
+       req->params1 = width;
+       req->params2 = x;
+       req->params3 = y;
+       if (!_XReply(dpy, &rep))
+           return(NULL);
+       return (rep.param.l[0]);
+}
+
diff --git a/usr/src/new/X/Xlib/XCreateWinBat.c b/usr/src/new/X/Xlib/XCreateWinBat.c
new file mode 100644 (file)
index 0000000..a50c173
--- /dev/null
@@ -0,0 +1,66 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XCreateWinBat.c,v 10.5 86/04/22 15:26:22 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+
+int XCreateWindowBatch(defs, ndefs)
+       BatchFrame defs[];
+       int ndefs;
+{
+       register Display *dpy;
+       register int i;
+       register BatchFrame *frame = defs;
+       int nresult = 0;
+
+       /*
+        * Issue requests.
+        */
+       for (i=0; i < ndefs; i++) {
+           register XReq *req;
+           if (frame->type == IsOpaque) {
+               GetReq(X_CreateWindow, frame->parent);
+               req->params0 = frame->height;
+               req->params1 = frame->width;
+               req->params2 = frame->x;
+               req->params3 = frame->y;
+               req->param.l[2] = frame->border;
+               req->param.l[3] = frame->background;
+               req->func = (frame++)->bdrwidth;
+           }
+           else {
+               GetReq(X_CreateTransparency, frame->parent);
+               req->params0 = frame->height;
+               req->params1 = frame->width;
+               req->params2 = frame->x;
+               req->params3 = (frame++)->y;
+           }
+       }
+       
+       /*
+        * Reset request number to its old value, so that
+        * error packets are processed correctly.
+        */
+       dpy->request -= ndefs;
+
+       /*
+        * Retrieve replies.
+        */
+       frame = defs;
+       for (i=0;i<ndefs;i++) {
+           XRep rep;
+           /*
+            * Increment request number so error packets
+            * are processed correctly.
+            */
+           dpy->request++;
+           if (!_XReply(dpy, &rep)) (frame++)->self = NULL;
+           else {
+               (frame++)->self = rep.param.l[0];
+               nresult++;
+           }
+       }
+       return (nresult);
+}
+
diff --git a/usr/src/new/X/Xlib/XCreateWindow.c b/usr/src/new/X/Xlib/XCreateWindow.c
new file mode 100644 (file)
index 0000000..2f6f700
--- /dev/null
@@ -0,0 +1,28 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XCreateWindow.c,v 10.5 86/04/22 15:27:38 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+Window XCreateWindow (parent, x, y, width, height, bdr_width, border, bgnd)
+       int x, y, width, height, bdr_width;
+       Window parent;
+       Pixmap border, bgnd;
+{
+       register Display *dpy;
+       register XReq *req;
+       XRep rep;
+
+       GetReq(X_CreateWindow, parent);
+       req->params0 = height;
+       req->params1 = width;
+       req->params2 = x;
+       req->params3 = y;
+       req->param.l[2] = border;
+       req->param.l[3] = bgnd;
+       req->func = bdr_width;
+       if (!_XReply(dpy, &rep))
+           return(NULL);
+       return (rep.param.l[0]);
+}
+
diff --git a/usr/src/new/X/Xlib/XCreateWinds.c b/usr/src/new/X/Xlib/XCreateWinds.c
new file mode 100644 (file)
index 0000000..e688060
--- /dev/null
@@ -0,0 +1,48 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XCreateWinds.c,v 10.5 86/04/22 15:27:41 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+int XCreateWindows (parent, defs, ndefs)
+       Window parent;
+       OpaqueFrame defs[];
+       int ndefs;
+{
+       register Display *dpy;
+       register int i;
+       register OpaqueFrame *frame = defs;
+       int nresult = 0;
+
+       for (i=0;i<ndefs;i++) {
+           register XReq *req;
+           GetReq(X_CreateWindow, parent);
+           req->params0 = frame->height;
+           req->params1 = frame->width;
+           req->params2 = frame->x;
+           req->params3 = frame->y;
+           req->param.l[2] = frame->border;
+           req->param.l[3] = frame->background;
+           req->func = (frame++)->bdrwidth;
+           }
+       
+       /* Reset request number to its old value, so that
+           error packets are processed correctly.  */
+       dpy->request -= ndefs;
+
+       frame = defs;
+       for (i=0;i<ndefs;i++) {
+           XRep rep;
+           /* Increment request number so error packets
+              are processed correctly. */
+           dpy->request++;
+           if (!_XReply(dpy, &rep))
+               (frame++)->self = NULL;
+           else {
+               (frame++)->self = rep.param.l[0];
+               nresult++;
+               }
+           }
+       return (nresult);
+}
+
diff --git a/usr/src/new/X/Xlib/XDefineCursor.c b/usr/src/new/X/Xlib/XDefineCursor.c
new file mode 100644 (file)
index 0000000..5de7247
--- /dev/null
@@ -0,0 +1,16 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XDefineCursor.c,v 10.4 86/02/01 15:31:52 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XDefineCursor (w, cursor)
+       Window w;
+       Cursor cursor;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_DefineCursor, w);
+       req->param.l[0] = cursor;
+}
diff --git a/usr/src/new/X/Xlib/XDestSubWind.c b/usr/src/new/X/Xlib/XDestSubWind.c
new file mode 100644 (file)
index 0000000..2da46ce
--- /dev/null
@@ -0,0 +1,15 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XDestSubWind.c,v 10.4 86/02/01 15:32:11 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XDestroySubwindows (w)
+       Window w;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_DestroySubwindows, w);
+}
+
diff --git a/usr/src/new/X/Xlib/XDestWindow.c b/usr/src/new/X/Xlib/XDestWindow.c
new file mode 100644 (file)
index 0000000..7ea38f4
--- /dev/null
@@ -0,0 +1,15 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XDestWindow.c,v 10.4 86/02/01 15:32:17 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XDestroyWindow (w)
+       Window w;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_DestroyWindow, w);
+}
+
diff --git a/usr/src/new/X/Xlib/XDisplayName.c b/usr/src/new/X/Xlib/XDisplayName.c
new file mode 100644 (file)
index 0000000..3fb580b
--- /dev/null
@@ -0,0 +1,35 @@
+/* $Header: XDisplayName.c,v 10.1 86/11/19 18:17:19 jg Rel $ */
+
+/* XDisplayName.c */
+/* 
+ * Returns the name of the display XOpenDisplay would use.  This is better
+ * than just printing the "display" variable in a program because that
+ * could be NULL and/or there could be an environment variable set.
+ * This makes it easier for programmers to provide meaningful error
+ * messages. 
+ *
+ * 
+ * For example, this is used in XOpenDisplay() as
+ *     strncpy( displaybuf, XDisplayName( display ), sizeof(displaybuf) );
+ *      if ( *displaybuf == '\0' ) return( NULL );
+ *  This check is actually unnecessary because the next thing is an index()
+ *  call looking for a ':' which will fail and we'll return(NULL).
+ */
+/* Written at Waterloo - JMSellens */
+
+#include <stdio.h>
+
+char *getenv();
+
+
+char *
+XDisplayName( display )
+char *display;
+{
+    char *d;
+    if ( display != (char *)NULL && *display != '\0' )
+       return( display );
+    if ( (d = getenv( "DISPLAY" )) != (char *)NULL )
+       return( d );
+    return( "" );
+}
diff --git a/usr/src/new/X/Xlib/XDraw.c b/usr/src/new/X/Xlib/XDraw.c
new file mode 100644 (file)
index 0000000..756ecae
--- /dev/null
@@ -0,0 +1,29 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XDraw.c,v 10.6 86/04/22 15:27:13 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XDraw (w, vlist, vcount, width, height, pixel, func, planes)
+       Window w;
+       int func;
+       int pixel, planes, height, width, vcount;
+       Vertex *vlist;
+{
+       register Display *dpy;
+       register XReq *req;
+       int nbytes;
+
+       GetReq(X_Draw, w);
+       dpy->lastdraw = (caddr_t)req;
+       req->func = func;
+       req->mask = planes;
+       req->params0 = vcount;
+       req->paramu1 = pixel;
+       req->param.b[4] = height;
+       req->param.b[5] = width;
+       req->params3 = DrawSolidLine;
+       nbytes = vcount*psizeof(Vertex);
+       PackData(dpy, vlist, nbytes);
+}
+
diff --git a/usr/src/new/X/Xlib/XDrawDashed.c b/usr/src/new/X/Xlib/XDrawDashed.c
new file mode 100644 (file)
index 0000000..3c6f19f
--- /dev/null
@@ -0,0 +1,33 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XDrawDashed.c,v 10.7 86/11/06 17:47:14 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XDrawDashed (w, vlist, vcount, width, height, pixel, pattern, func, planes)
+       Window w;
+       int func;
+       int pixel, planes, height, width, vcount;
+       Pattern pattern;
+       Vertex *vlist;
+{
+       register Display *dpy;
+       register XReq *req;
+       int nbytes;
+
+       GetReq(X_Draw, w);
+       dpy->lastdraw = (caddr_t) req;
+       req->func = func;
+       req->mask = planes;
+       req->params0 = vcount;
+       req->paramu1 = pixel;
+       req->param.b[4] = height;
+       req->param.b[5] = width;
+       req->params3 = DrawDashedLine;
+       req->params5 = pattern & 0xffff;  /* pattern string */
+       req->params6 = ((pattern & 0xf0000) >> 16) + 1;  /* pattern length */
+       req->params7 = (pattern & 0xfff00000) >> 20;  /* pattern multiplier */
+       nbytes = vcount*psizeof(Vertex);
+       PackData(dpy, vlist, nbytes);
+}
+
diff --git a/usr/src/new/X/Xlib/XDrawFilled.c b/usr/src/new/X/Xlib/XDrawFilled.c
new file mode 100644 (file)
index 0000000..f625095
--- /dev/null
@@ -0,0 +1,27 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XDrawFilled.c,v 10.6 86/04/22 15:24:31 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XDrawFilled (w, vlist, vcount, pixel, func, planes)
+       Window w;
+       int func;
+       int pixel, planes, vcount;
+       Vertex *vlist;
+{
+       register Display *dpy;
+       register XReq *req;
+       int nbytes;
+
+       GetReq(X_DrawFilled, w);
+       dpy->lastdraw = (caddr_t) req;
+       req->func = func;
+       req->mask = planes;
+       req->params0 = vcount;
+       req->paramu1 = pixel;
+       req->param.l[1] = 0;  /* means "no tile--use pixel" */
+       nbytes = vcount*psizeof(Vertex);
+       PackData(dpy, vlist, nbytes);
+}
+
diff --git a/usr/src/new/X/Xlib/XDrawPatternd.c b/usr/src/new/X/Xlib/XDrawPatternd.c
new file mode 100644 (file)
index 0000000..5b20875
--- /dev/null
@@ -0,0 +1,35 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XDrawPatternd.c,v 10.7 86/11/06 17:47:38 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XDrawPatterned (w, vlist, vcount, width, height, pixel, altpix, pattern,
+    func, planes)
+       Window w;
+       int func;
+       int pixel, altpix, planes, height, width, vcount;
+       Pattern pattern;
+       Vertex *vlist;
+{
+       register Display *dpy;
+       register XReq *req;
+       int nbytes;
+
+       GetReq(X_Draw, w);
+       dpy->lastdraw = (caddr_t) req;
+       req->func = func;
+       req->mask = planes;
+       req->params0 = vcount;
+       req->paramu1 = pixel;
+       req->param.b[4] = height;
+       req->param.b[5] = width;
+       req->params3 = DrawPatternedLine;
+       req->paramu4 = altpix;
+       req->params5 = pattern & 0xffff;  /* pattern string */
+       req->params6 = ((pattern & 0xf0000) >> 16) + 1;  /* pattern length */
+       req->params7 = (pattern & 0xfff00000) >> 20;  /* pattern multiplier */
+       nbytes = vcount*psizeof (Vertex);
+       PackData(dpy, vlist, nbytes);
+}
+
diff --git a/usr/src/new/X/Xlib/XDrawTiled.c b/usr/src/new/X/Xlib/XDrawTiled.c
new file mode 100644 (file)
index 0000000..746f172
--- /dev/null
@@ -0,0 +1,27 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XDrawTiled.c,v 10.6 86/04/22 15:23:22 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XDrawTiled (w, vlist, vcount, tile, func, planes)
+       Window w;
+       int func;
+       int planes, vcount;
+       Pixmap tile;
+       Vertex *vlist;
+{
+       register Display *dpy;
+       register XReq *req;
+       int nbytes;
+
+       GetReq(X_DrawFilled, w);
+       dpy->lastdraw = (caddr_t) req;
+       req->func = func;
+       req->mask = planes;
+       req->params0 = vcount;
+       req->param.l[1] = tile;
+       nbytes = vcount*psizeof(Vertex);
+       PackData(dpy, vlist, nbytes);
+}
+
diff --git a/usr/src/new/X/Xlib/XErrDescrip.c b/usr/src/new/X/Xlib/XErrDescrip.c
new file mode 100644 (file)
index 0000000..f25856d
--- /dev/null
@@ -0,0 +1,33 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XErrDescrip.c,v 10.4 86/02/01 15:32:52 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+#define num_error_codes 13
+
+char *XErrorList[num_error_codes + 1] = {
+       /* No error             */      "",
+       /* BadRequest           */      "bad request code",
+       /* BadValue             */      "integer parameter out of range",
+       /* BadWindow            */      "parameter not a Window",
+       /* BadPixmap            */      "parameter not a Pixmap",
+       /* BadBitmap            */      "parameter not a Bitmap",
+       /* BadCursor            */      "parameter not a Cursor",
+       /* BadFont              */      "parameter not a Font",
+       /* BadMatch             */      "parameter mismatch",
+       /* BadTile              */      "Pixmap shape invalid for tiling",
+       /* BadGrab              */      "button/mouse already grabbed",
+       /* BadAccess            */      "access control violation",
+       /* BadAlloc             */      "insufficient resources",
+       /* BadColor             */      "no such color",
+};
+
+char *XErrDescrip (code)
+    register int code;
+{
+    if (code <= num_error_codes && code > 0)
+       return (XErrorList[code]);
+    return("Unknown error");
+}
+
diff --git a/usr/src/new/X/Xlib/XErrHndlr.c b/usr/src/new/X/Xlib/XErrHndlr.c
new file mode 100644 (file)
index 0000000..8eea09b
--- /dev/null
@@ -0,0 +1,25 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XErrHndlr.c,v 10.5 86/11/24 15:05:45 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+#undef _XError
+extern int _XError();
+
+/* 
+ * XErrorHandler - This proceedure sets the X non-fatal error handler
+ * (_XErrorFunction) to be the specified routine.  If NULL is passed in
+ * the original error handler is restored.
+ */
+XErrorHandler(handler)
+    register int (*handler)();
+{
+    if (handler != NULL) {
+       _XErrorFunction = handler;
+    }
+    else {
+       _XErrorFunction = _XError;
+    }
+}
diff --git a/usr/src/new/X/Xlib/XExpandEvents.c b/usr/src/new/X/Xlib/XExpandEvents.c
new file mode 100644 (file)
index 0000000..b3de0e9
--- /dev/null
@@ -0,0 +1,17 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XExpandEvents.c,v 10.4 86/02/01 15:33:09 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+
+/*
+ * XExpandEvents - Compress MouseMoved events such that all MouseMoved
+ * events that are recieved are returned.
+ */
+XExpandEvents()
+{
+       _XlibCurrentDisplay->squish = 0;
+}
+
diff --git a/usr/src/new/X/Xlib/XFeep.c b/usr/src/new/X/Xlib/XFeep.c
new file mode 100644 (file)
index 0000000..d287b6e
--- /dev/null
@@ -0,0 +1,23 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XFeep.c,v 10.5 86/04/22 15:28:06 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+
+/*
+ * XFeep - Ring the display's bell.  The sound volume is in the range -7
+ * to 7 and is added to the base volume as defined by XFeepControl.  Large
+ * numbers represent louder volumes.
+ */
+
+XFeep(volume)
+       int volume;
+{
+       register Display *dpy = _XlibCurrentDisplay;
+       register XReq *req;
+
+       GetReq(X_Feep, dpy->root);
+       req->params0 = volume;
+}
+
diff --git a/usr/src/new/X/Xlib/XFeepControl.c b/usr/src/new/X/Xlib/XFeepControl.c
new file mode 100644 (file)
index 0000000..2364044
--- /dev/null
@@ -0,0 +1,22 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XFeepControl.c,v 10.4 86/02/01 15:33:24 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+
+/*
+ * XFeepControl - Define the base volume for XFeep requests.  The volume
+ * is in the range 0 to 7 with 7 being the loudest.
+ */
+
+XFeepControl(volume)
+       int volume;
+{
+       register Display *dpy = _XlibCurrentDisplay;
+       register XReq *req;
+
+       GetReq(X_FeepControl, dpy->root);
+       req->func = volume;
+}
+
diff --git a/usr/src/new/X/Xlib/XFetchBuffer.c b/usr/src/new/X/Xlib/XFetchBuffer.c
new file mode 100644 (file)
index 0000000..db310ab
--- /dev/null
@@ -0,0 +1,30 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XFetchBuffer.c,v 10.5 86/04/22 15:28:15 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+
+caddr_t XFetchBuffer (nbytes, buffer)
+       register int *nbytes;
+       int buffer;
+{
+       register Display *dpy;
+       register XReq *req;
+       XRep rep;
+       char *data;
+
+       GetReq(X_FetchBytes, 0);
+       req->func = buffer;
+       if (!_XReply(dpy, &rep))
+           return(NULL);
+       if ((*nbytes = rep.params0) == 0)
+           return (NULL);  /* empty cut buffer */
+       if ((data = (char *) malloc(*nbytes)) == NULL) {
+           errno = ENOMEM;
+           _XIOError(dpy);
+           }
+       _XReadPad (dpy, data, *nbytes);
+       return(data);
+}
+
diff --git a/usr/src/new/X/Xlib/XFetchBytes.c b/usr/src/new/X/Xlib/XFetchBytes.c
new file mode 100644 (file)
index 0000000..b3b0a8d
--- /dev/null
@@ -0,0 +1,29 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XFetchBytes.c,v 10.5 86/04/22 15:28:57 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+
+caddr_t XFetchBytes (nbytes)
+       register int *nbytes;
+{
+       register Display *dpy;
+       register XReq *req;
+       XRep rep;
+       char *data;
+
+       GetReq(X_FetchBytes, 0);
+       req->func = 0;  /* cut buffer 0 */
+       if (!_XReply(dpy, &rep))
+           return(NULL);
+       if ((*nbytes = rep.params0) == 0)
+           return (NULL);  /* empty cut buffer */
+       if ((data = (char *) malloc(*nbytes)) == NULL) {
+           errno = ENOMEM;
+           _XIOError(dpy);
+           }
+       _XReadPad (dpy, data, *nbytes);
+       return(data);
+}
+
diff --git a/usr/src/new/X/Xlib/XFetchName.c b/usr/src/new/X/Xlib/XFetchName.c
new file mode 100644 (file)
index 0000000..d7017f2
--- /dev/null
@@ -0,0 +1,36 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XFetchName.c,v 10.5 86/04/22 15:29:04 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+
+Status XFetchName (w, name)
+       Window w;
+       char **name;
+{
+       register Display *dpy;
+       register XReq *req;
+       XRep rep;
+       register int nbytes;
+
+       GetReq(X_FetchName, w);
+       if (!_XReply(dpy, &rep)) {
+           /* error */
+           *name = NULL;
+           return(0);
+           }
+       if ((nbytes = rep.params0) == 0) {
+           /* no name set */
+           *name = NULL;
+           return(1);
+           }
+       if ((*name = (char *) malloc(nbytes + 1)) == NULL) {
+           errno = ENOMEM;
+           _XIOError(dpy);
+           }
+       _XReadPad (dpy, *name, nbytes);
+       (*name)[nbytes] = '\0';
+       return (1);
+}
+
diff --git a/usr/src/new/X/Xlib/XFlush.c b/usr/src/new/X/Xlib/XFlush.c
new file mode 100644 (file)
index 0000000..cd6ddf5
--- /dev/null
@@ -0,0 +1,14 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XFlush.c,v 10.4 86/02/01 15:33:43 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+
+/* Flush all buffered output requests. */
+/* NOTE: NOT necessary when calling any of the Xlib routines. */
+
+XFlush ()
+    {
+    _XFlush (_XlibCurrentDisplay);
+    }
diff --git a/usr/src/new/X/Xlib/XFocusKbd.c b/usr/src/new/X/Xlib/XFocusKbd.c
new file mode 100644 (file)
index 0000000..05d28d0
--- /dev/null
@@ -0,0 +1,16 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XFocusKbd.c,v 10.4 86/02/01 15:33:49 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XFocusKeyboard (w)
+       Window w;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_FocusKeyboard, w);
+       req->func = 0;  /* "for future expansion", sez X.doc */
+}
+
diff --git a/usr/src/new/X/Xlib/XFontWidths.c b/usr/src/new/X/Xlib/XFontWidths.c
new file mode 100644 (file)
index 0000000..11e230a
--- /dev/null
@@ -0,0 +1,37 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XFontWidths.c,v 10.6 86/04/22 15:21:46 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+
+short *XFontWidths (font)
+       Font font;
+{
+       register Display *dpy;
+       register XReq *req;
+       XRep rep;
+       short *buf;
+       int nbytes;
+
+       GetReq(X_FontWidths, 0);
+       req->param.l[0] = font;
+       if (!_XReply(dpy, &rep))
+           return(NULL);
+       nbytes = rep.param.l[0];
+       if ((buf = (short *) malloc(nbytes*sizeof(short)/psizeof(short))) == NULL) {
+           errno = ENOMEM;
+           _XIOError(dpy);
+       }
+#ifdef BIGSHORTS
+       {
+        ushort_p *proto_shorts = (ushort_p *) malloc (nbytes);
+       _XReadPad (dpy, (char *)proto_shorts, nbytes);
+       UnpackShorts(proto_shorts, buf, nbytes);
+       free((char *)proto_shorts);
+       }
+#else
+       _XReadPad(dpy, (char *)buf, nbytes);
+#endif
+       return (buf);
+}
diff --git a/usr/src/new/X/Xlib/XFreeBitmap.c b/usr/src/new/X/Xlib/XFreeBitmap.c
new file mode 100644 (file)
index 0000000..5b949c5
--- /dev/null
@@ -0,0 +1,16 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XFreeBitmap.c,v 10.4 86/02/01 15:34:02 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XFreeBitmap (bitmap)
+       Bitmap bitmap;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_FreeBitmap, 0);
+       req->param.l[0] = bitmap;
+}
+
diff --git a/usr/src/new/X/Xlib/XFreeColors.c b/usr/src/new/X/Xlib/XFreeColors.c
new file mode 100644 (file)
index 0000000..5c4d913
--- /dev/null
@@ -0,0 +1,35 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XFreeColors.c,v 10.5 86/04/22 15:19:33 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XFreeColors (pixels, npixels, planes)
+       register int *pixels;
+       int npixels;
+       int planes;
+{
+       register Display *dpy;
+       register XReq *req;
+       
+       GetReq (X_FreeColors, 0);
+       req->mask = planes;
+       req->params0 = npixels;
+
+       /* "pixels" is an array of ints, but the protocol wants
+        * an array of shorts, therefore data must be copied */
+       {
+       register int i;
+       int nbytes = npixels*psizeof(short);
+#ifdef BIGSHORTS
+       PackData(dpy, (short *)pixels, nbytes);
+#else
+       register u_short *proto_pixels = (u_short *) malloc (nbytes);
+       for (i=0;i<npixels;i++)
+           proto_pixels[i] = pixels[i];
+       Data (dpy, proto_pixels, nbytes);
+       free ((char *)proto_pixels);
+#endif
+       }
+}
+
diff --git a/usr/src/new/X/Xlib/XFreeCursor.c b/usr/src/new/X/Xlib/XFreeCursor.c
new file mode 100644 (file)
index 0000000..7338c4e
--- /dev/null
@@ -0,0 +1,16 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XFreeCursor.c,v 10.4 86/02/01 15:34:13 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XFreeCursor (cursor)
+       Cursor cursor;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_FreeCursor, 0);
+       req->param.l[0] = cursor;
+}
+
diff --git a/usr/src/new/X/Xlib/XFreeFont.c b/usr/src/new/X/Xlib/XFreeFont.c
new file mode 100644 (file)
index 0000000..3219856
--- /dev/null
@@ -0,0 +1,16 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XFreeFont.c,v 10.4 86/02/01 15:34:19 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XFreeFont (font)
+       Font font;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_FreeFont, 0);
+       req->param.l[0] = font;
+}
+
diff --git a/usr/src/new/X/Xlib/XFreePixmap.c b/usr/src/new/X/Xlib/XFreePixmap.c
new file mode 100644 (file)
index 0000000..31b5458
--- /dev/null
@@ -0,0 +1,20 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XFreePixmap.c,v 10.5 86/02/01 15:34:23 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XFreePixmap (pixmap)
+       register Pixmap pixmap;
+{
+       register Display *dpy = _XlibCurrentDisplay;
+       register XReq *req;
+       
+       if (pixmap == dpy->black || pixmap == dpy->white)
+           return;  /* don't free the constant tile pixmaps! */
+
+       GetReq(X_FreePixmap, 0);
+       req->param.l[0] = pixmap;
+       return;
+}
+
diff --git a/usr/src/new/X/Xlib/XGeom.c b/usr/src/new/X/Xlib/XGeom.c
new file mode 100644 (file)
index 0000000..abe0e43
--- /dev/null
@@ -0,0 +1,48 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XGeom.c,v 10.6 86/08/04 09:52:35 wesommer Rel $/
+/* Copyright Massachusetts Institute of Technology 1985 */
+
+#include "XlibInternal.h"
+
+/*
+ * This routine given a user supplied positional argument and a default
+ * argument (fully qualified) will return the position the window should take
+ * returns 0 if there was some problem, else the position bitmask.
+ */
+
+int XGeometry (pos, def, bwidth, fwidth, fheight, xadd, yadd, x, y, width, height)
+char *pos;                             /* user provided geometry spec */
+char *def;                             /* default geometry spec for window */
+int bwidth;                            /* border width */
+int fwidth, fheight;                   /* size of position units */
+int xadd, yadd;                                /* any additional interior space */
+register *x, *y, *width, *height;      /* always set on successful RETURN */
+{
+       int px, py, pwidth, pheight;    /* returned values from parse */
+       int dx, dy, dwidth, dheight;    /* default values from parse */
+       int pmask, dmask;               /* values back from parse */
+
+       pmask = XParseGeometry(pos, &px, &py, &pwidth, &pheight);
+       dmask = XParseGeometry(def, &dx, &dy, &dwidth, &dheight);
+
+       /* set default values */
+       *x = (dmask & XNegative) ? 
+           DisplayWidth()  + dx - dwidth * fwidth - 2 * bwidth - xadd : dx;
+       *y = (dmask & YNegative) ? 
+           DisplayHeight() + dy - dheight * fheight - 2 * bwidth - yadd : dy;
+       *width  = dwidth;
+       *height = dheight;
+
+       if (pmask & WidthValue)  *width  = pwidth;
+       if (pmask & HeightValue) *height = pheight;
+
+       if (pmask & XValue)
+           *x = (pmask & XNegative) ?
+             DisplayWidth()  + px - *width * fwidth - 2 * bwidth - xadd : px;
+       if (pmask & YValue)
+           *y = (pmask & YNegative) ?
+             DisplayHeight() + py - *height * fheight - 2 * bwidth - yadd: py;
+
+       return (pmask);
+}
diff --git a/usr/src/new/X/Xlib/XGetColCells.c b/usr/src/new/X/Xlib/XGetColCells.c
new file mode 100644 (file)
index 0000000..1933470
--- /dev/null
@@ -0,0 +1,49 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XGetColCells.c,v 10.5 86/04/22 15:30:25 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+Status XGetColorCells (contig, ncolors, nplanes, planes, pixels)
+       int contig;
+       int ncolors;
+       int nplanes;
+       int *planes;
+       register int pixels[];
+{
+       register Display *dpy;
+       register XReq *req;
+       XRep rep;
+
+       GetReq (X_GetColorCells, 0);
+       req->func = contig;
+       req->params0 = ncolors;
+       req->params1 = nplanes;
+       if (!_XReply (dpy, &rep)) {
+           *planes = 0;
+           return (0);
+           }
+       *planes = rep.paramu0;
+       if (!ncolors)
+           return (1);
+
+       /* "pixels" is an array of ints, but the protocol
+        * returns an array of shorts.  Therefore data must be copied. */
+       {
+       register int i;
+       int nbytes = ncolors*2;
+#ifdef BIGSHORTS
+       register ushort_p *proto_pixels = (ushort_p *) malloc (nbytes);
+       _XReadPad (dpy, (char *)proto_pixels, nbytes);
+       UnpackShorts(proto_pixels, (short *)pixels, nbytes);
+#else
+       register u_short *proto_pixels = (u_short *) malloc (nbytes);
+       _XReadPad (dpy, proto_pixels, nbytes);
+       for (i=0;i<ncolors;i++)
+           pixels[i] = proto_pixels[i];
+#endif
+       free ((char *)proto_pixels);
+       return (1);
+       }
+}
+
diff --git a/usr/src/new/X/Xlib/XGetColor.c b/usr/src/new/X/Xlib/XGetColor.c
new file mode 100644 (file)
index 0000000..8d69429
--- /dev/null
@@ -0,0 +1,36 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XGetColor.c,v 10.5 86/04/22 15:17:03 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+
+Status XGetColor (name, hard_def, exact_def)
+    char *name;
+    register Color *exact_def, *hard_def;
+    {
+    register Display *dpy;
+    register XReq *req;
+    XRep rep;
+    int namelen = strlen (name);
+
+    GetReq (X_LookupColor, 0);
+    req->params0 = namelen;
+    Data (dpy, name, namelen);
+    if (!_XReply (dpy, &rep))
+       return (0);
+
+    exact_def->red = rep.paramu0;
+    exact_def->green = rep.paramu1;
+    exact_def->blue = rep.paramu2;
+
+    GetReq (X_GetColor, 0);
+    hard_def->red = req->params0 = rep.paramu3;
+    hard_def->green = req->params1 = rep.paramu4;
+    hard_def->blue = req->params2 = rep.paramu5;
+    if (!_XReply (dpy, &rep))
+       return (0);
+
+    hard_def->pixel = exact_def->pixel = rep.paramu0;
+    return (1);
+    }
diff --git a/usr/src/new/X/Xlib/XGetDefault.c b/usr/src/new/X/Xlib/XGetDefault.c
new file mode 100644 (file)
index 0000000..0d82153
--- /dev/null
@@ -0,0 +1,242 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XGetDefault.c,v 10.7 86/12/01 14:50:34 jg Rel $ */
+/* Copyright (c) 1985, Massachusetts Institute of Technology */
+
+/*
+ * This routine returns options out of the X user preferences file
+ * found in XDEFAULT, possibly modified by the .Xdefaults in the user's home
+ * directory.  It either returns a pointer to
+ * the option or returns NULL if option not set.  It is patterned after
+ * Andrew's file format (why be different for the sake of being different?).
+ * Andrew's code was NOT examined before writing this routine.
+ * It parses lines of the format "progname.option:value" and returns a pointer
+ * to value.
+ */
+
+#include <stdio.h>
+#include <strings.h>
+#include <ctype.h>
+#include "Xdefault.h"
+
+#define XOPTIONFILE "/.Xdefaults"      /* name in home directory of options
+                                          file. */
+extern char *malloc();
+
+static struct ent {
+       struct ent *left;               /* next option to left          */
+       struct ent *right;              /* next option to right         */
+       char *oname;                    /* option name                  */
+       char *value;                    /* value for that option        */
+       char bal;                       /* for avl use                  */
+} *head;
+
+char *XGetDefault(prog, name)
+       register char *name;            /* name of option program wants */
+       char *prog;                     /* name of program for option   */
+{                                      /* to get, for example, "font"  */
+       static nent = -1;               /* have we been here before?    */
+       register struct ent *cur;       /* current entry being examined */
+       register int cmp;
+       char namebuf[64];
+       register char *pv = namebuf;
+
+       strncpy(namebuf, name, sizeof(namebuf));
+       while (*pv) {                   /* convert upper to lower       */
+               if (isupper(*pv))  *pv += 040;
+               pv++;
+       }
+       if (nent == -1)
+               nent = ReadFile(prog);/* if not, parse the file.*/
+       if (nent == 0)
+               return(NULL);
+       cur = head;
+       do {
+               if ((cmp = strcmp(namebuf, cur->oname)) == 0)
+                       return(cur->value);
+               cur = cmp > 0 ? cur->right : cur->left;
+       } while (cur != NULL);
+       return(NULL);                   /* if no match, let him know    */
+}
+
+static ReadFile(prog)
+       char *prog;                     /* program name to match            */
+{
+       register char *point,*colon;    /* where in the line the keys are   */
+       register char *oname, *val;     /* new memory for valid option line */
+       register FILE *fptr = NULL;     /* preferences file                 */
+       register char *pv;              /* pointer to value for lowering    */
+       register int len;
+       register int nentries = 0;      /* number of entries found          */
+       register int first;
+       char fname[BUFSIZ];             /* longer than any conceivable size */
+       char line[BUFSIZ];              /* line buffer for each line of file*/
+       char *getenv();
+       char *home = getenv("HOME");
+
+       if ((pv = rindex(prog,'/')) != NULL)
+               prog = pv + 1;  /* if full path, get last component */
+    for(first = 1 ; first >= 0 ; first--) {
+       if(first)       /* Use any defaults in XDEFAULTS. */
+               fptr = fopen(XDEFAULTS, "r");
+       else if (home != NULL) {                /* try home directory */
+               strcpy(fname, home);    /* form full path name of file  */
+               strcat(fname, XOPTIONFILE);
+               fptr = fopen(fname, "r");
+       } else
+               break;
+       if(fptr == NULL)
+               continue;
+       while ( fgets(line, sizeof(line), fptr) != NULL ) {
+               if (line[0] == '#') continue;           /* comment?     */
+               point = index(line,'.');
+               colon = index(line,':');
+               if ( (point == NULL) || (colon == NULL) || (colon < point) )
+                       continue;       /* both . and : required on line*/
+               *point = 0;
+               if ( point != line )    /* check all chars up to '.'    */
+                       if (strcmp(line, prog) != 0)
+                               continue;
+
+               /* 
+                * ok, we've passed all the tests, so it is a valid option for
+                * this program, or is global option.
+                */
+
+               len = strlen(colon);
+               if(colon[len-1] == '\n')
+                       colon[len-1] = '\0';    /* braindamaged fgets call */
+               /*
+                * allocate space for text
+                */
+               point++;
+               len = colon - point;
+               for(colon++ ; isspace(*colon) ; colon++); /* skip over spaces */
+               if((oname = malloc(len + strlen(colon) + 2)) == NULL) {
+                       fprintf(stderr, "ReadFile: Out of memory\n");
+                       exit(1);
+               }
+               strncpy(oname, point, len);
+               oname[len] = 0;
+               pv = oname;
+               while (*pv) {           /* convert upper to lower       */
+                       if (isupper(*pv))
+                               *pv += 040;
+                       pv++;
+               }
+               val = oname + len + 1;
+               strcpy(val, colon);
+               insert(oname, val, &head);
+               nentries++;
+       }
+       fclose(fptr);
+    }
+       return(nentries);
+}
+
+/*
+ * Modified from "Algorithms + Data Structures = Programs", Niklaus Wirth,
+ * 1976, section 4.4.7 Balanced Tree Insertion, page 220-221.
+ */
+#define        L_EQUILIBRATED  2
+#define        LEFTSLANTED     1
+#define        L_REBALANCE     0
+
+#define        R_EQUILIBRATED  0
+#define        RIGHTSLANTED    1
+#define        R_REBALANCE     2
+
+static insert(name, val, ent)
+register char *name, *val;
+register struct ent **ent;
+{
+       register struct ent *ent1, *ent2;
+       register int cmp;
+       char *calloc();
+
+       if(*ent == NULL) {      /* not in tree, insert it */
+               if((*ent = (struct ent *)calloc(1, sizeof(struct ent))) ==
+                NULL) {
+                       fprintf(stderr, "insert: Out of memory\n");
+                       exit(1);
+               }
+               (*ent)->oname = name;
+               (*ent)->value = val;
+               (*ent)->bal = LEFTSLANTED;
+               return(1);
+       }
+       if((cmp = strcmp(name, (*ent)->oname)) == 0) {  /* match */
+               free((*ent)->oname);
+               (*ent)->oname = name;
+               (*ent)->value = val;
+               return(0);
+       }
+       if(cmp < 0) {
+               if(!insert(name, val, &(*ent)->left))
+                       return(0);
+               /* left branch has grown higher */
+               switch((*ent)->bal) {
+                case L_EQUILIBRATED:
+                       (*ent)->bal = LEFTSLANTED;
+                       return(0);
+                case LEFTSLANTED:
+                       (*ent)->bal = L_REBALANCE;
+                       return(1);
+                case L_REBALANCE:      /* rebalance */
+                       if((ent1 = (*ent)->left)->bal == L_REBALANCE) {
+                         /* single LL rotation */
+                               (*ent)->left = ent1->right;
+                               ent1->right = *ent;
+                               (*ent)->bal = LEFTSLANTED;
+                               *ent = ent1;
+                       } else {
+                         /* double LR rotation */
+                               ent2 = ent1->right;
+                               ent1->right = ent2->left;
+                               ent2->left = ent1;
+                               (*ent)->left = ent2->right;
+                               ent2->right = *ent;
+                               (*ent)->bal = (ent2->bal == L_REBALANCE) ?
+                                L_EQUILIBRATED : LEFTSLANTED;
+                               ent1->bal = (ent2->bal == L_EQUILIBRATED) ?
+                                L_REBALANCE : LEFTSLANTED;
+                               *ent = ent2;
+                       }
+                       (*ent)->bal = LEFTSLANTED;
+                       return(0);
+               }
+       }
+       if(!insert(name, val, &(*ent)->right))
+               return(0);
+       /* right branch has grown higher */
+       switch((*ent)->bal) {
+        case R_EQUILIBRATED:
+               (*ent)->bal = RIGHTSLANTED;
+               return(0);
+        case RIGHTSLANTED:
+               (*ent)->bal = R_REBALANCE;
+               return(1);
+        case R_REBALANCE:      /* rebalance */
+               if((ent1 = (*ent)->right)->bal == R_REBALANCE) {
+                 /* single RR rotation */
+                       (*ent)->right = ent1->left;
+                       ent1->left = *ent;
+                       (*ent)->bal = RIGHTSLANTED;
+                       *ent = ent1;
+               } else {
+                 /* double RL rotation */
+                       ent2 = ent1->left;
+                       ent1->left = ent2->right;
+                       ent2->right = ent1;
+                       (*ent)->right = ent2->left;
+                       ent2->left = *ent;
+                       (*ent)->bal = (ent2->bal == R_REBALANCE) ?
+                        R_EQUILIBRATED : RIGHTSLANTED;
+                       ent1->bal = (ent2->bal == R_EQUILIBRATED) ?
+                        R_REBALANCE : RIGHTSLANTED;
+                       *ent = ent2;
+               }
+               (*ent)->bal = RIGHTSLANTED;
+               return(0);
+       }
+}
diff --git a/usr/src/new/X/Xlib/XGetFont.c b/usr/src/new/X/Xlib/XGetFont.c
new file mode 100644 (file)
index 0000000..a435c97
--- /dev/null
@@ -0,0 +1,22 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XGetFont.c,v 10.5 86/04/22 15:29:34 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+Font XGetFont (name)
+       char *name;
+{
+       register XReq *req;
+       Display *dpy;
+       XRep rep;
+       int len;
+
+       GetReq(X_GetFont, 0);
+       req->params0 = len = strlen (name);
+       Data(dpy, name, len);
+       if (!_XReply(dpy, &rep))
+           return(NULL);
+       return (rep.param.l[0]);
+}
+
diff --git a/usr/src/new/X/Xlib/XGetHardColor.c b/usr/src/new/X/Xlib/XGetHardColor.c
new file mode 100644 (file)
index 0000000..2ec5850
--- /dev/null
@@ -0,0 +1,24 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XGetHardColor.c,v 10.5 86/04/22 15:30:21 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+Status XGetHardwareColor (color)
+       register Color *color;
+{
+       register Display *dpy;
+       register XReq *req;
+       XRep rep;
+       Status status;
+
+       GetReq (X_GetColor, 0);
+       req->paramu0 = color->red;
+       req->paramu1 = color->green;
+       req->paramu2 = color->blue;
+       status = _XReply (dpy, &rep);
+       if (status)
+           color->pixel = rep.paramu0;
+       return (status);
+}
+
diff --git a/usr/src/new/X/Xlib/XGetHosts.c b/usr/src/new/X/Xlib/XGetHosts.c
new file mode 100644 (file)
index 0000000..31fbaa0
--- /dev/null
@@ -0,0 +1,31 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XGetHosts.c,v 10.4 86/02/01 15:35:02 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+struct in_addr *XGetHosts (nhosts)
+       int *nhosts;
+{
+       register Display *dpy;
+       register XReq *req;
+       XRep rep;
+       char *buf;
+       int nbytes;
+
+       GetReq(X_GetHosts, 0);
+       req->func = XAF_INET;
+       if (!(_XReply (dpy, &rep)) || !(nbytes = rep.param.l[0])) {
+           /* error or empty list */
+           *nhosts = 0;
+           return (NULL);
+           }
+       *nhosts = nbytes / sizeof (struct in_addr);
+       if (!(buf = (char *) malloc (nbytes))) {
+           errno = ENOMEM;
+           _XIOError (dpy);
+           }
+       _XReadPad (dpy, buf, nbytes);
+       return ((struct in_addr *) buf);
+}
+
diff --git a/usr/src/new/X/Xlib/XGetIconWind.c b/usr/src/new/X/Xlib/XGetIconWind.c
new file mode 100644 (file)
index 0000000..1f80af7
--- /dev/null
@@ -0,0 +1,18 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XGetIconWind.c,v 10.4 86/02/01 15:35:07 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+Window XGetIconWindow (w)
+       Window w;
+{
+       register Display *dpy;
+       register XReq *req;
+       XRep rep;
+
+       GetReq(X_QueryWindow, w);
+       if (!_XReply(dpy, &rep))
+           return(NULL);
+       return (rep.param.b[11] == IsIcon ? w : rep.param.l[3]); 
+       }
diff --git a/usr/src/new/X/Xlib/XGetNodes.c b/usr/src/new/X/Xlib/XGetNodes.c
new file mode 100644 (file)
index 0000000..a13376c
--- /dev/null
@@ -0,0 +1,36 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XGetNodes.c,v 10.2 86/02/01 15:35:11 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+#include "XlibInternal.h"
+#ifdef DNETCONN
+#include <netdnet/dn.h>
+#endif
+struct dn_naddr *XGetNodes (nnodes)
+       int *nnodes;
+{
+#ifdef DNETCONN
+       register Display *dpy;
+       register XReq *req;
+       XRep rep;
+       char *buf;
+       int nbytes;
+       GetReq(X_GetHosts, 0);
+       req->func = XAF_DECnet;
+       if (!(_XReply (dpy, &rep)) || !(nbytes = rep.param.l[0])) {
+           /* error or empty list */
+           *nnodes = 0;
+           return (NULL);
+           }
+       *nnodes = nbytes / sizeof (struct dn_naddr);
+       if (!(buf = (char *) malloc (nbytes))) {
+           errno = ENOMEM;
+           _XIOError (dpy);
+           }
+       _XReadPad (dpy, buf, nbytes);
+       return ((struct dn_naddr *) buf);
+#endif
+}
diff --git a/usr/src/new/X/Xlib/XGetResHint.c b/usr/src/new/X/Xlib/XGetResHint.c
new file mode 100644 (file)
index 0000000..a2e411f
--- /dev/null
@@ -0,0 +1,24 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XGetResHint.c,v 10.5 86/04/22 15:31:44 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+Status XGetResizeHint (w, width0, height0, widthinc, heightinc)
+       Window w;
+       int *width0, *widthinc, *height0, *heightinc;
+{
+       register Display *dpy;
+       register XReq *req;
+       XRep rep;
+
+       GetReq(X_GetResizeHint, w);
+       if (!_XReply(dpy, &rep))
+           return (0);
+       *height0 = rep.params0;
+       *heightinc = rep.params1;
+       *width0 = rep.params2;
+       *widthinc = rep.params3;
+       return (1);
+}
+
diff --git a/usr/src/new/X/Xlib/XGrabButton.c b/usr/src/new/X/Xlib/XGrabButton.c
new file mode 100644 (file)
index 0000000..3392c2c
--- /dev/null
@@ -0,0 +1,22 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XGrabButton.c,v 10.4 86/02/01 15:35:22 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+Status XGrabButton (w, cursor, buttonMask, eventMask)
+       Window w;
+       Cursor cursor;
+       int buttonMask, eventMask;
+{
+       register Display *dpy;
+       register XReq *req;
+       XRep rep;
+
+       GetReq(X_GrabButton, w);
+       req->mask = buttonMask;
+       req->param.l[0] = cursor;
+       req->param.l[1] = eventMask;
+       return((_XReply(dpy, &rep)));
+}
+
diff --git a/usr/src/new/X/Xlib/XGrabMouse.c b/usr/src/new/X/Xlib/XGrabMouse.c
new file mode 100644 (file)
index 0000000..6e4ab24
--- /dev/null
@@ -0,0 +1,21 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XGrabMouse.c,v 10.4 86/02/01 15:35:26 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+Status XGrabMouse (w, cursor, mask)
+       Window w;
+       Cursor cursor;
+       int mask;
+{
+       register Display *dpy;
+       register XReq *req;
+       XRep rep;
+
+       GetReq(X_GrabMouse, w);
+       req->param.l[0] = cursor;
+       req->param.l[1] = mask;
+       return(_XReply(dpy, &rep));
+}
+
diff --git a/usr/src/new/X/Xlib/XGrabServer.c b/usr/src/new/X/Xlib/XGrabServer.c
new file mode 100644 (file)
index 0000000..4657acc
--- /dev/null
@@ -0,0 +1,14 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XGrabServer.c,v 10.4 86/02/01 15:35:31 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XGrabServer ()
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_GrabServer, 0);
+}
+
diff --git a/usr/src/new/X/Xlib/XIOErrHndlr.c b/usr/src/new/X/Xlib/XIOErrHndlr.c
new file mode 100644 (file)
index 0000000..090211b
--- /dev/null
@@ -0,0 +1,25 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XIOErrHndlr.c,v 10.5 86/11/24 15:05:59 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+#undef _XIOError
+extern int _XIOError();
+
+/* 
+ * XIOErrorHandler - This proceedure sets the X fatal I/O error handler
+ * (_XIOErrorFunction) to be the specified routine.  If NULL is passed in 
+ * the original error handler is restored.
+ */
+XIOErrorHandler(handler)
+    register int (*handler)();
+{
+    if (handler != NULL) {
+       _XIOErrorFunction = handler;
+    }
+    else {
+       _XIOErrorFunction = _XIOError;
+    }
+}
diff --git a/usr/src/new/X/Xlib/XInterpLoc.c b/usr/src/new/X/Xlib/XInterpLoc.c
new file mode 100644 (file)
index 0000000..e92ca2d
--- /dev/null
@@ -0,0 +1,26 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XInterpLoc.c,v 10.5 86/04/22 15:32:21 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+Status XInterpretLocator (w, x, y, subw, loc)
+       Window w;
+       Window *subw;
+       Locator loc;
+       int *x, *y;
+{
+       register Display *dpy;
+       register XReq *req;
+       XRep rep;
+
+       GetReq(X_InterpretLocator, w);
+       req->param.l[0] = loc;
+       if (!_XReply(dpy, &rep))
+           return(0);
+       *x = rep.params2;
+       *y = rep.params3;
+       *subw = rep.param.l[0];
+       return (1);
+}
+
diff --git a/usr/src/new/X/Xlib/XKeyClickCon.c b/usr/src/new/X/Xlib/XKeyClickCon.c
new file mode 100644 (file)
index 0000000..aca8360
--- /dev/null
@@ -0,0 +1,23 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XKeyClickCon.c,v 10.4 86/02/01 15:36:00 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+
+/*
+ * XKeyClickControl  -  Controls the volume of the "click" that the
+ * keyboard makes when a key is pressed.  0 if "off", 8 is the loudest
+ * volume.  Initially volume is set to 6.
+ */
+
+XKeyClickControl(volume)
+       int volume;
+{
+       register XReq *req;
+       register Display *dpy;
+
+       GetReq(X_KeyClick, 0);
+       req->func = volume;
+}
+
diff --git a/usr/src/new/X/Xlib/XLine.c b/usr/src/new/X/Xlib/XLine.c
new file mode 100644 (file)
index 0000000..da57bc0
--- /dev/null
@@ -0,0 +1,26 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XLine.c,v 10.5 86/04/22 15:30:18 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XLine (w, x1, y1, x2, y2, width, height, pixel, func, planes)
+       Window w;
+       int pixel, width, height, func, planes;
+       int x1, y1, x2, y2;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_Line, w);
+       req->func = func;
+       req->mask = planes;
+       req->params0 = x1;
+       req->params1 = y1;
+       req->params2 = x2;
+       req->params3 = y2;
+       req->paramu4 = pixel;
+       req->param.b[10] = height;
+       req->param.b[11] = width;
+}
+
diff --git a/usr/src/new/X/Xlib/XLockToggle.c b/usr/src/new/X/Xlib/XLockToggle.c
new file mode 100644 (file)
index 0000000..0392d41
--- /dev/null
@@ -0,0 +1,17 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XLockToggle.c,v 10.4 86/02/01 15:36:10 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+
+
+XLockToggle ()
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_ShiftLock, 0);
+       req->func = LockToggleMode;
+}
+
diff --git a/usr/src/new/X/Xlib/XLockUpDown.c b/usr/src/new/X/Xlib/XLockUpDown.c
new file mode 100644 (file)
index 0000000..71aa43d
--- /dev/null
@@ -0,0 +1,17 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XLockUpDown.c,v 10.4 86/02/01 15:36:15 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+
+
+XLockUpDown ()
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_ShiftLock, 0);
+       req->func = LockUpDownMode;
+}
+
diff --git a/usr/src/new/X/Xlib/XLowerWindow.c b/usr/src/new/X/Xlib/XLowerWindow.c
new file mode 100644 (file)
index 0000000..7439903
--- /dev/null
@@ -0,0 +1,15 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XLowerWindow.c,v 10.4 86/02/01 15:36:28 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XLowerWindow (w)
+       Window w;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_LowerWindow, w);
+}
+
diff --git a/usr/src/new/X/Xlib/XMakePattern.c b/usr/src/new/X/Xlib/XMakePattern.c
new file mode 100644 (file)
index 0000000..02cd807
--- /dev/null
@@ -0,0 +1,28 @@
+/* $Header: XMakePattern.c,v 1.1 86/04/22 15:15:16 jg Rel $ */
+
+/* 
+ * XMakePattern.c - Substitute for macro in the library
+ * 
+ * Author:     Scott Nettles
+ *             Digital Equipment Corporation
+ *             Western Research Laboratory
+ * Date:       Sat Aug 24 1985
+ */
+
+/* $Log:       XMakePattern.c,v $
+ * Revision 1.1  86/04/22  15:15:16  jg
+ * Changes to hide protocol better for BIGSHORTS
+ * 
+ * Revision 1.1  85/12/05  13:34:57  nettles
+ * Initial revision
+ *  */
+
+static char rcs_ident[] = "$Header: XMakePattern.c,v 1.1 86/04/22 15:15:16 jg Rel $";
+
+typedef long Pattern;
+
+Pattern XMakePattern(pattern, patlen, patmul)
+int    pattern, patlen, patmul;
+{
+    return     ((Pattern)(((patmul) << 20) | (((patlen) - 1) << 16) | (pattern) ));
+}
diff --git a/usr/src/new/X/Xlib/XMakePixmap.c b/usr/src/new/X/Xlib/XMakePixmap.c
new file mode 100644 (file)
index 0000000..16ccb81
--- /dev/null
@@ -0,0 +1,23 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XMakePixmap.c,v 10.4 86/02/01 15:36:39 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+Pixmap XMakePixmap (bitmap, foreground, background)
+       Bitmap bitmap;
+       int foreground, background;
+{
+       register Display *dpy;
+       register XReq *req;
+       XRep rep;
+
+       GetReq(X_MakePixmap, 0);
+       req->param.l[0] = bitmap;
+       req->param.u[2] = foreground;
+       req->param.u[3] = background;
+       if (!_XReply (dpy, &rep))
+           return (NULL);
+       return (rep.param.l[0]);
+}
+
diff --git a/usr/src/new/X/Xlib/XMakeTile.c b/usr/src/new/X/Xlib/XMakeTile.c
new file mode 100644 (file)
index 0000000..c991cd9
--- /dev/null
@@ -0,0 +1,26 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XMakeTile.c,v 10.4 86/02/01 15:36:44 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+Pixmap XMakeTile (pixel)
+       int pixel;
+{
+       register Display *dpy;
+       register XReq *req;
+       XRep rep;
+       
+       switch (pixel) {
+           case WhitePixel: return (_XlibCurrentDisplay->white);
+           case BlackPixel: return (_XlibCurrentDisplay->black);
+           }
+
+       GetReq(X_MakePixmap, 0);
+       req->param.l[0] = 0;
+       req->param.s[2] = pixel;
+       if (!_XReply (dpy, &rep))
+           return (NULL);
+       return (rep.param.l[0]);
+}
+
diff --git a/usr/src/new/X/Xlib/XMakeTiles.c b/usr/src/new/X/Xlib/XMakeTiles.c
new file mode 100644 (file)
index 0000000..577728b
--- /dev/null
@@ -0,0 +1,93 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XMakeTiles.c,v 10.3 86/02/01 15:36:49 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+
+int XMakeTiles(defs, ndefs)
+    TileFrame defs[];
+    register int ndefs;
+{
+    register int i;
+    register int req_count = 0;
+    register int res_count = 0;
+    register Display *dpy = _XlibCurrentDisplay;
+    register TileFrame *frame = defs;
+    
+    
+    /*
+     * Issue requests.
+     */
+    for (i = 0; i < ndefs; i++) {
+       register XReq *req;
+       switch (frame->pixel) {
+           case WhitePixel:
+               frame->pixmap = dpy->white;
+               break;
+           case BlackPixel:
+               frame->pixmap = dpy->black;
+               break;
+           default:
+               GetReq(X_MakePixmap, 0);
+               frame->pixmap = 0;
+               req->param.l[0] = 0;
+               req->param.s[2] = frame->pixel;
+               req_count++;
+               break;
+       }
+       /*
+        * Increment the frame pointer.
+        */
+       frame++;
+    }
+
+    /*
+     * Reset request number to its old value, so that
+     * error packets are processed correctly.
+     */
+    dpy->request -= req_count;
+
+    /*
+     * Retrieve replies.
+     */
+    frame = defs;
+    for (i = 0; i < ndefs; i++) {
+       XRep rep;
+
+       /*
+        * If the pixel was a degenerate case (white or black)
+        * then we already have the pixmap id, increment the
+        * result frame pointer and result count and continue.
+        */
+       if (frame->pixmap != 0) {
+           res_count++;
+       }
+       else {
+           /*
+            * Increment request number so error packets
+            * are processed correctly.
+            */
+           dpy->request++;
+
+           /*
+            * Retrieve the reply.
+            */
+           if (!_XReply(dpy, &rep)) frame->pixmap = 0;
+           else {
+               frame->pixmap = rep.param.l[0];
+               res_count++;
+           }
+       }
+       /*
+        * Increment the frame pointer.
+        */
+       frame++;
+    }
+
+    /*
+     * Return the number of successful pixmaps.
+     */
+    return (res_count);
+}
+
diff --git a/usr/src/new/X/Xlib/XMapSubWind.c b/usr/src/new/X/Xlib/XMapSubWind.c
new file mode 100644 (file)
index 0000000..ad0f227
--- /dev/null
@@ -0,0 +1,23 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XMapSubWind.c,v 10.4 86/02/01 15:36:55 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XMapSubwindows (w)
+       Window w;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_MapSubwindows, w);
+}
+
+
+
+
+
+
+
+
+
diff --git a/usr/src/new/X/Xlib/XMapWindow.c b/usr/src/new/X/Xlib/XMapWindow.c
new file mode 100644 (file)
index 0000000..e22882c
--- /dev/null
@@ -0,0 +1,15 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XMapWindow.c,v 10.4 86/02/01 15:37:00 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XMapWindow (w)
+       Window w;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_MapWindow, w);
+}
+
diff --git a/usr/src/new/X/Xlib/XMaskEvent.c b/usr/src/new/X/Xlib/XMaskEvent.c
new file mode 100644 (file)
index 0000000..637a441
--- /dev/null
@@ -0,0 +1,52 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XMaskEvent.c,v 10.5 86/04/22 15:19:51 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+
+extern _QEvent *_qfree;
+
+/* 
+ * Flush output and (wait for and) return the next event in the queue
+ * matching one of the events in the mask.
+ * Events earlier in the queue are not discarded.
+ */
+
+XMaskEvent (mask, event)
+       int mask;               /* Selected event mask. */
+       register XEvent *event; /* XEvent to be filled in. */
+{
+       register Display *dpy;
+       register _QEvent *prev, *qelt;
+
+       dpy = _XlibCurrentDisplay;
+       _XFlush (dpy);
+       for (prev = NULL, qelt = dpy->head;
+            qelt &&  !(qelt->event.type & mask);
+            qelt = (prev = qelt)->next) ;
+       if (qelt) {
+           *event = qelt->event;
+           if (prev) {
+               if ((prev->next = qelt->next) == NULL)
+                   dpy->tail = prev;
+           } else {
+               if ((dpy->head = qelt->next) == NULL)
+                   dpy->tail = NULL;
+           }
+           qelt->next = _qfree;
+           _qfree = qelt;
+           dpy->qlen--;
+           return;
+       }
+       while (1) {
+           _XRead (dpy, (char *)event, sizeof(XEvent));
+           if (event->type == X_Error)
+               _XError(dpy, (XErrorEvent *) event);
+           else if (event->type & mask)
+               return;
+           else
+               _XEnq(dpy, event);
+       }
+}
+
diff --git a/usr/src/new/X/Xlib/XMouseControl.c b/usr/src/new/X/Xlib/XMouseControl.c
new file mode 100644 (file)
index 0000000..4373f88
--- /dev/null
@@ -0,0 +1,19 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XMouseControl.c,v 10.4 86/02/01 15:37:10 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+
+
+XMouseControl(accel, thresh)
+       int accel, thresh;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_MouseControl, 0);
+       req->param.s[0] = accel;
+       req->param.s[1] = thresh;
+}
+
diff --git a/usr/src/new/X/Xlib/XMoveArea.c b/usr/src/new/X/Xlib/XMoveArea.c
new file mode 100644 (file)
index 0000000..c54f29d
--- /dev/null
@@ -0,0 +1,24 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XMoveArea.c,v 10.4 86/02/01 15:37:15 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XMoveArea (w, srcX, srcY, dstX, dstY, width, height)
+       Window w;
+       int srcX, srcY, dstX, dstY, width, height;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_CopyArea, w);
+       req->func = GXcopy;
+       req->mask = ~0;  /* all planes */
+       req->param.s[0] = height;
+       req->param.s[1] = width;
+       req->param.s[2] = srcX;
+       req->param.s[3] = srcY;
+       req->param.s[6] = dstX;
+       req->param.s[7] = dstY;
+}
+
diff --git a/usr/src/new/X/Xlib/XMoveWindow.c b/usr/src/new/X/Xlib/XMoveWindow.c
new file mode 100644 (file)
index 0000000..78916be
--- /dev/null
@@ -0,0 +1,19 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XMoveWindow.c,v 10.5 86/04/22 15:16:10 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XMoveWindow (w, x, y)
+       Window w;
+       int x, y;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_MoveWindow, w);
+       req->func = 0;  /* "for future expansion", sez X.doc */
+       req->params0 = x;
+       req->params1 = y;
+}
+
diff --git a/usr/src/new/X/Xlib/XNextEvent.c b/usr/src/new/X/Xlib/XNextEvent.c
new file mode 100644 (file)
index 0000000..4a92123
--- /dev/null
@@ -0,0 +1,63 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XNextEvent.c,v 10.4 86/02/01 15:37:26 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+
+extern _QEvent *_qfree;
+
+/* Flush output and (wait for and) return the next event in the queue.
+*/
+
+XNextEvent (event)
+       register XEvent *event;
+{
+       register _QEvent *qelt;
+       register Display *dpy = _XlibCurrentDisplay;
+       
+       _XFlush (dpy);
+       
+       /* if the queue is empty, read as many events as possible
+          and enqueue them */
+       while (dpy->head == NULL) {
+           char buf[BUFSIZE];
+           int pend_not_register; /* because can't "&" a register variable */
+           register int pend;
+           register XRep *rep;
+
+           /* find out how much data can be read */
+           if (ioctl(dpy->fd, FIONREAD, &pend_not_register) < 0)
+               _XIOError(dpy);
+           pend = pend_not_register;
+
+           /* must read at least one XRep; if none is pending, then
+              we'll just block waiting for it */
+           if (pend < sizeof(XRep))
+               pend = sizeof (XRep);
+               
+           /* but we won't read more than the max buffer size */
+           if (pend > BUFSIZE)
+               pend = BUFSIZE;
+
+           /* round down to an integral number of XReps */
+           pend = (pend / sizeof (XRep)) * sizeof (XRep);
+
+           _XRead (dpy, buf, pend);
+           for (rep = (XRep *) buf; pend > 0; rep++, pend -= sizeof(XRep))
+               if (rep->code == X_Error)
+                   _XError (dpy, (XErrorEvent *) rep);
+               else  /* it's an event packet; enqueue it */
+                   _XEnq (dpy, (XEvent *) rep);
+           }
+
+       *event = (qelt = dpy->head)->event;
+
+       /* move the head of the queue to the free list */
+       if ((dpy->head = qelt->next) == NULL)
+           dpy->tail = NULL;
+       qelt->next = _qfree;
+       _qfree = qelt;
+       dpy->qlen--;
+}
+
diff --git a/usr/src/new/X/Xlib/XOpenFont.c b/usr/src/new/X/Xlib/XOpenFont.c
new file mode 100644 (file)
index 0000000..1662a8c
--- /dev/null
@@ -0,0 +1,25 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XOpenFont.c,v 10.4 86/02/01 15:37:37 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+
+FontInfo *XOpenFont (name)
+    char *name;
+    {
+    Font font = XGetFont (name);
+    FontInfo *info;
+    if (!font)
+       return (NULL);
+    info = (FontInfo *) malloc (sizeof (FontInfo));
+    if (!info) {
+       errno = ENOMEM;
+       _XIOError (_XlibCurrentDisplay);
+       }
+    XQueryFont (font, info);
+    if (!info->fixedwidth)
+       info->widths = XFontWidths (font);
+    return (info);
+    }
+       
diff --git a/usr/src/new/X/Xlib/XParseColor.c b/usr/src/new/X/Xlib/XParseColor.c
new file mode 100644 (file)
index 0000000..22c8140
--- /dev/null
@@ -0,0 +1,59 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XParseColor.c,v 10.5 86/04/22 15:16:46 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+
+Status XParseColor (spec, def)
+       register char *spec;
+       Color *def;
+{
+       register Display *dpy;
+       register XReq *req;
+       XRep rep;
+       register int n, i;
+       int r, g, b;
+       char c;
+
+       n = strlen (spec);
+       if (*spec != '#') {
+           GetReq (X_LookupColor, 0);
+           req->params0 = n;
+           Data (dpy, spec, n);
+           if (!_XReply (dpy, &rep))
+               return (0);
+           def->red = rep.paramu0;
+           def->green = rep.paramu1;
+           def->blue = rep.paramu2;
+           return (1);
+       }
+       spec++;
+       n--;
+       if (n != 3 && n != 6 && n != 9 && n != 12)
+           return (0);
+       n /= 3;
+       r = g = b = 0;
+       do {
+           r = g;
+           g = b;
+           b = 0;
+           for (i = n; --i >= 0; ) {
+               c = *spec++;
+               b <<= 4;
+               if (c >= '0' && c <= '9')
+                   b |= c - '0';
+               else if (c >= 'A' && c <= 'F')
+                   b |= c - ('A' - 10);
+               else if (c >= 'a' && c <= 'f')
+                   b |= c - ('a' - 10);
+               else return (0);
+           }
+       } while (*spec);
+       n <<= 2;
+       n = 16 - n;
+       def->red = r << n;
+       def->green = g << n;
+       def->blue = b << n;
+       return (1);
+}
diff --git a/usr/src/new/X/Xlib/XParseGeom.c b/usr/src/new/X/Xlib/XParseGeom.c
new file mode 100644 (file)
index 0000000..a814ee2
--- /dev/null
@@ -0,0 +1,70 @@
+#include <X/mit-copyright.h>
+
+/* Copyright   Massachusetts Institute of Technology  1985 */
+/* $Header: XParseGeom.c,v 10.9 86/02/01 15:37:45 tony Rel $ */
+#include "XlibInternal.h"
+
+/* 
+ *Returns pointer to first char ins search which is also in what, else NULL.
+ */
+static char *strscan (search, what)
+char *search, *what;
+{
+       int i, len = strlen (what);
+       char c;
+
+       while ((c = *(search++)) != NULL)
+       for (i = 0; i < len; i++)
+       if (c == what [i]) return (--search);
+       return (NULL);
+}
+
+/*
+ *    XParseGeometry parses strings of the form
+ *   "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
+ *   width, height, xoffset, and yoffset are unsigned integers.
+ *   Example:  "=80x24+300-49"
+ *   The equal sign is optional.
+ *   It returns a bitmask that indicates which of the four values
+ *   were actually found in the string.  For each value found,
+ *   the corresponding argument is updated;  for each value
+ *   not found, the corresponding argument is left unchanged. 
+ */
+
+int XParseGeometry (string, x, y, width, height)
+char *string;
+int *x, *y, *width, *height;    /* RETURN */
+{
+       int mask = NoValue;
+       char *strind;
+       char *index();
+
+       if ( (string == NULL) || (*string == '\0')) return(mask);
+       if (*string == '=')
+       string++;  /* ignore possible '=' at beginning of geometry spec */
+
+       strind = string;
+       if (*strind != '+' && *strind != '-' && *strind != 'x') {
+               *width = atoi (strind);
+               mask |= WidthValue;
+       }
+
+       if (strind = index (string, 'x')) {
+               *height = atoi (++strind);
+               mask |= HeightValue;
+       }
+       else strind = string;
+
+       if (strind = strscan (strind, "+-")) {
+               if (*strind == '-') mask |= XNegative;
+               *x = atoi (strind++);
+               mask |= XValue;
+               if (strind = strscan (strind, "+-")) {
+                       if (*strind == '-') mask |= YNegative;
+                       *y = atoi (strind);
+                       mask |= YValue;
+               }
+       }
+       return (mask);
+}
+
diff --git a/usr/src/new/X/Xlib/XPeekEvent.c b/usr/src/new/X/Xlib/XPeekEvent.c
new file mode 100644 (file)
index 0000000..5bebfbb
--- /dev/null
@@ -0,0 +1,36 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XPeekEvent.c,v 10.5 86/04/22 15:21:50 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+
+extern _QEvent *_qfree;
+
+/* Flush output and (wait for and) return the next event in the queue,
+*  BUT do not remove it from the queue.
+*/
+
+XPeekEvent (event)
+       register XEvent *event;
+{
+       register _QEvent *qelt;
+       register Display *dpy = _XlibCurrentDisplay;
+       
+       _XFlush (dpy);
+       if (qelt = dpy->head) {
+           *event = qelt->event;
+           return;
+           }
+
+       while (1) {
+           _XRead (dpy, (char *)event, sizeof(XEvent));
+           if (event->type == X_Error)
+               _XError (dpy, (XErrorEvent *) event);
+           else {  /* it's an event packet */
+               _XEnq (dpy, event);
+               return;
+               }
+       }
+}
+
diff --git a/usr/src/new/X/Xlib/XPending.c b/usr/src/new/X/Xlib/XPending.c
new file mode 100644 (file)
index 0000000..ce689da
--- /dev/null
@@ -0,0 +1,36 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XPending.c,v 10.4 86/02/01 15:37:51 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+
+/* Read in any pending events and return the number of queued events. */
+
+int XPending ()
+{
+       register int len;
+       int pend;
+       char buf[BUFSIZE];
+       register XRep *rep;
+       register Display *dpy = _XlibCurrentDisplay;
+       
+       _XFlush (dpy);
+       if (ioctl(dpy->fd, FIONREAD, &pend) < 0)
+           _XIOError(dpy);
+       if ((len = pend) < sizeof(XRep))
+           return(dpy->qlen);
+       else if (len > BUFSIZE)
+           len = BUFSIZE;
+       len /= sizeof(XRep);
+       pend = len * sizeof(XRep);
+       _XRead (dpy, buf, pend);
+       for (rep = (XRep *) buf; len > 0; rep++, len--) {
+           if (rep->code == X_Error)
+               _XError(dpy, (XErrorEvent *)rep);
+           else   /* must be an event packet */
+               _XEnq(dpy, (XEvent *) rep);
+       }
+       return(dpy->qlen);
+}
+
diff --git a/usr/src/new/X/Xlib/XPixBitsPutXY.c b/usr/src/new/X/Xlib/XPixBitsPutXY.c
new file mode 100644 (file)
index 0000000..f5a1016
--- /dev/null
@@ -0,0 +1,31 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XPixBitsPutXY.c,v 10.6 86/04/22 15:17:19 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XPixmapBitsPutXY (w, x, y, width, height, data, mask, func, planes)
+       Window w;
+       int x, y, width, height;
+       short *data;
+       Bitmap mask;
+       int func;
+       int planes;
+{
+       register Display *dpy;
+       register XReq *req;
+       int len;
+
+       GetReq(X_PixmapBitsPut, w);
+       req->mask = planes;
+       req->func = func;
+       req->params0 = height;
+       req->params1 = width;
+       req->params2 = x;
+       req->params3 = y;
+       req->params4 = XYFormat;
+       req->param.l[3] = mask;
+       len = XYPixmapSize (width, height, dpy->dplanes);
+       Data(dpy, (caddr_t)data, len);
+}
+
diff --git a/usr/src/new/X/Xlib/XPixBitsPutZ.c b/usr/src/new/X/Xlib/XPixBitsPutZ.c
new file mode 100644 (file)
index 0000000..e39f317
--- /dev/null
@@ -0,0 +1,33 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XPixBitsPutZ.c,v 10.5 86/04/22 15:18:02 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XPixmapBitsPutZ (w, x, y, width, height, data, mask, func, planes)
+       Window w;
+       int x, y, width, height;
+       caddr_t data;
+       Bitmap mask;
+       int func;
+       int planes;
+{
+       register Display *dpy;
+       register XReq *req;
+       int len;
+
+       GetReq(X_PixmapBitsPut, w);
+       req->mask = planes;
+       req->func = func;
+       req->params0 = height;
+       req->params1 = width;
+       req->params2 = x;
+       req->params3 = y;
+       req->params4 = ZFormat;
+       req->param.l[3] = mask;
+       len = (dpy->dplanes > 8)
+         ? WZPixmapSize (width, height)
+         : BZPixmapSize (width, height);
+       Data (dpy, data, len);
+}
+
diff --git a/usr/src/new/X/Xlib/XPixFill.c b/usr/src/new/X/Xlib/XPixFill.c
new file mode 100644 (file)
index 0000000..d5c1b33
--- /dev/null
@@ -0,0 +1,28 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XPixFill.c,v 10.5 86/04/22 15:18:31 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XPixFill (w, x, y, width, height, pixel, clipmask, func, planes)
+       Window w;
+       int x, y;
+       int pixel;
+       int width, height;
+       Bitmap clipmask;
+       int func, planes;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_PixFill, w);
+       req->mask = planes;
+       req->func = func;
+       req->params0 = height;
+       req->params1 = width;
+       req->params2 = x;
+       req->params3 = y;
+       req->paramu4 = pixel;
+       req->param.l[3] = clipmask;
+}
+
diff --git a/usr/src/new/X/Xlib/XPixSet.c b/usr/src/new/X/Xlib/XPixSet.c
new file mode 100644 (file)
index 0000000..b3323dc
--- /dev/null
@@ -0,0 +1,26 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XPixSet.c,v 10.5 86/04/22 15:19:21 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XPixSet (w, x, y, width, height, pixel)
+       Window w;
+       int x, y;
+       int pixel;
+       int width, height;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_PixFill, w);
+       req->mask = ~0;  /* all planes */
+       req->func = GXcopy;
+       req->params0 = height;
+       req->params1 = width;
+       req->params2 = x;
+       req->params3 = y;
+       req->params4 = pixel;
+       req->param.l[3] = 0;  /* no mask bitmap */
+}
+
diff --git a/usr/src/new/X/Xlib/XPixmapGetXY.c b/usr/src/new/X/Xlib/XPixmapGetXY.c
new file mode 100644 (file)
index 0000000..e45d56c
--- /dev/null
@@ -0,0 +1,26 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XPixmapGetXY.c,v 10.6 86/04/22 15:19:40 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+Status XPixmapGetXY (w, x, y, width, height, data)
+    Window w;
+    int x, y, width, height;
+    short *data;
+{
+    register Display *dpy;
+    register XReq *req;
+    XRep rep;
+
+    GetReq (X_PixmapGet, w);
+    req->func = XYFormat;
+    req->params0 = height;
+    req->params1 = width;
+    req->params2 = x;
+    req->params3 = y;
+    if (!_XReply (dpy, &rep))
+       return(0);
+    _XReadPad (dpy, (char *)data, XYPixmapSize (width, height, dpy->dplanes));
+    return (1);
+}
diff --git a/usr/src/new/X/Xlib/XPixmapGetZ.c b/usr/src/new/X/Xlib/XPixmapGetZ.c
new file mode 100644 (file)
index 0000000..adf8209
--- /dev/null
@@ -0,0 +1,29 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XPixmapGetZ.c,v 10.5 86/04/22 15:20:08 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+Status XPixmapGetZ (w, x, y, width, height, data)
+    Window w;
+    int x, y, width, height;
+    caddr_t data;
+{
+    register Display *dpy;
+    register XReq *req;
+    XRep rep;
+
+    GetReq (X_PixmapGet, w);
+    req->func = ZFormat;
+    req->params0 = height;
+    req->params1 = width;
+    req->params2 = x;
+    req->params3 = y;
+    if (!_XReply (dpy, &rep))
+       return(0);
+    if (dpy->dplanes > 8)
+       _XReadPad (dpy, data, WZPixmapSize (width, height));
+    else 
+       _XReadPad (dpy, data, BZPixmapSize (width, height));
+    return (1);
+}
diff --git a/usr/src/new/X/Xlib/XPixmapPut.c b/usr/src/new/X/Xlib/XPixmapPut.c
new file mode 100644 (file)
index 0000000..24f6e83
--- /dev/null
@@ -0,0 +1,29 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XPixmapPut.c,v 10.6 86/04/22 15:21:00 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XPixmapPut (w, source_x, source_y, dest_x, dest_y, 
+width, height, pixmap, func, planes)
+       Window w;
+       int source_x, source_y, dest_x, dest_y, width, height;
+       Pixmap pixmap;
+       int func, planes;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_PixmapPut, w);
+       req->mask = planes;
+       req->func = func;
+       req->params0 = height;
+       req->params1 = width;
+       req->params2 = source_x;
+       req->params3 = source_y;
+       req->param.l[2] = pixmap;
+       req->params6 = dest_x;
+       req->params7 = dest_y;
+       return;
+}
+
diff --git a/usr/src/new/X/Xlib/XPixmapSave.c b/usr/src/new/X/Xlib/XPixmapSave.c
new file mode 100644 (file)
index 0000000..853443c
--- /dev/null
@@ -0,0 +1,24 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XPixmapSave.c,v 10.5 86/04/22 15:21:23 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+Pixmap XPixmapSave (w, x, y, width, height)
+       Window w;
+       int x, y, width, height;
+{
+       register Display *dpy;
+       register XReq *req;
+       XRep rep;
+
+       GetReq(X_PixmapSave, w);
+       req->params0 = height;
+       req->params1 = width;
+       req->params2 = x;
+       req->params3 = y;
+       if (!_XReply(dpy, &rep))
+           return(NULL);
+       return (rep.param.l[0]);
+}
+
diff --git a/usr/src/new/X/Xlib/XPutBackEvent.c b/usr/src/new/X/Xlib/XPutBackEvent.c
new file mode 100644 (file)
index 0000000..d8caccd
--- /dev/null
@@ -0,0 +1,28 @@
+#include <X/mit-copyright.h>
+
+/* Copyright   Massachusetts Institute of Technology  1985 */
+/* $Header: XPutBackEvent.c,v 10.5 86/02/01 15:38:34 tony Rel $ */
+/* XPutBackEvent puts an event back at the head of the queue. */
+
+#include "XlibInternal.h"
+
+extern _QEvent *_qfree;
+
+XPutBackEvent (event)
+       register XEvent *event;
+       {
+       register _QEvent *qelt;
+       register Display *dpy = _XlibCurrentDisplay;
+       if (!_qfree) {
+           _qfree = (_QEvent *) malloc (sizeof (_QEvent));
+           _qfree->next = NULL;
+           }
+       qelt = _qfree;
+       _qfree = qelt->next;
+       qelt->next = dpy->head;
+       qelt->event = *event;
+       dpy->head = qelt;
+       if (dpy->tail == NULL)
+           dpy->tail = qelt;
+       dpy->qlen++;
+       }
diff --git a/usr/src/new/X/Xlib/XQueryBrush.c b/usr/src/new/X/Xlib/XQueryBrush.c
new file mode 100644 (file)
index 0000000..1d0ffde
--- /dev/null
@@ -0,0 +1,22 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XQueryBrush.c,v 10.5 86/04/22 15:21:53 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XQueryBrushShape (width, height, rwidth, rheight)
+       int width, height, *rwidth, *rheight;
+{
+       register Display *dpy;
+       register XReq *req;
+       XRep rep;
+
+       GetReq(X_QueryShape, 0);
+       req->func = BrushShape;
+       req->params0 = height;
+       req->params1 = width;
+       _XReply (dpy, &rep);
+       *rheight = rep.params0;
+       *rwidth = rep.params1;
+}
+
diff --git a/usr/src/new/X/Xlib/XQueryButtons.c b/usr/src/new/X/Xlib/XQueryButtons.c
new file mode 100644 (file)
index 0000000..4b85333
--- /dev/null
@@ -0,0 +1,26 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XQueryButtons.c,v 10.5 86/04/22 15:22:41 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+Status XQueryMouseButtons (w, x, y, subw, state)
+       Window w;
+       Window *subw;
+       int *x, *y;
+       short *state;
+{
+       register Display *dpy;
+       register XReq *req;
+       XRep rep;
+
+       GetReq(X_QueryMouse, w);
+       if (!_XReply(dpy, &rep))
+           return (0);
+       *x = rep.params2;
+       *y = rep.params3;
+       *subw = rep.param.l[0];
+       *state = rep.params4;
+       return (1);
+}
+
diff --git a/usr/src/new/X/Xlib/XQueryColor.c b/usr/src/new/X/Xlib/XQueryColor.c
new file mode 100644 (file)
index 0000000..c277243
--- /dev/null
@@ -0,0 +1,21 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XQueryColor.c,v 10.5 86/04/22 15:22:55 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XQueryColor (color)
+       register Color *color;
+{
+       register Display *dpy;
+       register XReq *req;
+       XRep rep;
+
+       GetReq (X_QueryColor, 0);
+       req->paramu0 = color->pixel;
+       _XReply (dpy, &rep);
+       color->red = rep.paramu0;
+       color->green = rep.paramu1;
+       color->blue = rep.paramu2;
+}
+
diff --git a/usr/src/new/X/Xlib/XQueryColors.c b/usr/src/new/X/Xlib/XQueryColors.c
new file mode 100644 (file)
index 0000000..7fd5fa3
--- /dev/null
@@ -0,0 +1,43 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XQueryColors.c,v 10.5 86/04/22 15:23:30 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+#define MAXREQS 80  /* to prevent deadlock due to full TCP buffers */
+
+XQueryColors (colors, ncolors)
+       Color colors[];
+       int ncolors;
+{
+       register Display *dpy;
+       register XReq *req;
+       register int i;
+       register Color *color = colors;
+       XRep rep;
+
+       while (ncolors > 0) {
+           register int nreqs = (ncolors > MAXREQS) ? MAXREQS : ncolors;
+           for (i=0;i<nreqs;i++) {
+               GetReq (X_QueryColor, 0);
+               req->paramu0 = (color++)->pixel;
+               }
+
+           /* Reset request number, so error packets are handled correctly */
+           dpy->request -= nreqs;
+           color -= nreqs;
+
+           for (i=0;i<nreqs;i++) {
+               /* Increment request number, so error packets are handled
+                   correctly */
+               dpy->request++;
+               _XReply (dpy, &rep);
+               color->red = rep.paramu0;
+               color->green = rep.paramu1;
+               (color++)->blue = rep.paramu2;
+               }
+           
+           ncolors -= nreqs;
+           }
+}
+
diff --git a/usr/src/new/X/Xlib/XQueryCursor.c b/usr/src/new/X/Xlib/XQueryCursor.c
new file mode 100644 (file)
index 0000000..eb45c3b
--- /dev/null
@@ -0,0 +1,22 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XQueryCursor.c,v 10.5 86/04/22 15:23:26 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XQueryCursorShape (width, height, rwidth, rheight)
+       int width, height, *rwidth, *rheight;
+{
+       register Display *dpy;
+       register XReq *req;
+       XRep rep;
+
+       GetReq(X_QueryShape, 0);
+       req->func = CursorShape;
+       req->params0 = height;
+       req->params1 = width;
+       _XReply (dpy, &rep);
+       *rheight = rep.params0;
+       *rwidth = rep.params1;
+}
+
diff --git a/usr/src/new/X/Xlib/XQueryFont.c b/usr/src/new/X/Xlib/XQueryFont.c
new file mode 100644 (file)
index 0000000..676248c
--- /dev/null
@@ -0,0 +1,29 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XQueryFont.c,v 10.5 86/04/22 15:24:44 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+Status XQueryFont (font, info)
+       Font font;
+       register FontInfo *info;
+{
+       register Display *dpy;
+       register XReq *req;
+       XRep rep;
+
+       GetReq(X_QueryFont, 0);
+       req->param.l[0] = font;
+       if (!_XReply(dpy, &rep))
+           return (0);
+       info->id = font;
+       info->height = rep.params0;
+       info->width = rep.params1;
+       info->firstchar = (unsigned char) rep.params2;
+       info->lastchar = (unsigned char) rep.params3;
+       info->baseline = rep.params4;
+       info->fixedwidth = rep.params5;
+       info->widths = NULL;
+       return (1);
+}
+
diff --git a/usr/src/new/X/Xlib/XQueryInput.c b/usr/src/new/X/Xlib/XQueryInput.c
new file mode 100644 (file)
index 0000000..ad97f9d
--- /dev/null
@@ -0,0 +1,22 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XQueryInput.c,v 10.1 86/03/25 18:05:05 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+Status XQueryInput (w, mask)
+       Window w;
+       long *mask;
+{
+       register Display *dpy;
+       register XReq *req;
+       XRep rep;
+
+       GetReq(X_QueryWindow, w);
+
+       if (!_XReply(dpy, &rep))
+           return (0);
+       *mask = rep.param.l[4];
+       return (1);
+}
+
diff --git a/usr/src/new/X/Xlib/XQueryMouse.c b/usr/src/new/X/Xlib/XQueryMouse.c
new file mode 100644 (file)
index 0000000..4b4a034
--- /dev/null
@@ -0,0 +1,24 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XQueryMouse.c,v 10.5 86/04/22 15:25:29 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+Status XQueryMouse (w, x, y, subw)
+       Window w;
+       Window *subw;
+       int *x, *y;
+{
+       register Display *dpy;
+       register XReq *req;
+       XRep rep;
+
+       GetReq(X_QueryMouse, w);
+       if (!_XReply(dpy, &rep))
+           return (0);
+       *x = rep.params2;
+       *y = rep.params3;
+       *subw = rep.param.l[0];
+       return (1);
+}
+
diff --git a/usr/src/new/X/Xlib/XQueryTile.c b/usr/src/new/X/Xlib/XQueryTile.c
new file mode 100644 (file)
index 0000000..a60dd55
--- /dev/null
@@ -0,0 +1,22 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XQueryTile.c,v 10.5 86/04/22 15:26:04 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XQueryTileShape (width, height, rwidth, rheight)
+       int width, height, *rwidth, *rheight;
+{
+       register Display *dpy;
+       register XReq *req;
+       XRep rep;
+
+       GetReq(X_QueryShape, 0);
+       req->func = TileShape;
+       req->params0 = height;
+       req->params1 = width;
+       _XReply (dpy, &rep);
+       *rheight = rep.params0;
+       *rwidth = rep.params1;
+}
+
diff --git a/usr/src/new/X/Xlib/XQueryTree.c b/usr/src/new/X/Xlib/XQueryTree.c
new file mode 100644 (file)
index 0000000..926e651
--- /dev/null
@@ -0,0 +1,34 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XQueryTree.c,v 10.5 86/04/22 15:20:57 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+Status XQueryTree (w, parent, nchildren, children)
+       Window w;
+       Window *parent;
+       int *nchildren;
+       Window **children;
+
+{
+       register Display *dpy;
+       register XReq *req;
+       XRep rep;
+       int nbytes;
+
+       GetReq(X_QueryTree, w);
+
+       if (!_XReply(dpy, &rep))
+           return (0);
+       *parent = rep.param.l[0];
+       if ((*nchildren = rep.param.l[1]) == 0) {
+           *children = NULL;
+           return (1);
+           }
+       
+       if ((*children = (Window *) malloc (nbytes = rep.param.l[1]*sizeof(Window))) == NULL)
+           _XIOError (dpy);
+
+       _XRead (dpy, (char *)*children, nbytes);
+       return (1);
+       }
diff --git a/usr/src/new/X/Xlib/XQueryWidth.c b/usr/src/new/X/Xlib/XQueryWidth.c
new file mode 100644 (file)
index 0000000..1f803df
--- /dev/null
@@ -0,0 +1,28 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XQueryWidth.c,v 10.6 86/04/22 15:26:52 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+
+int XQueryWidth (str, font)
+       char *str;
+       Font font;
+{
+       register Display *dpy;
+       register XReq *req;
+       XRep rep;
+       int len;
+
+       if (str == NULL) return(0);
+       len = strlen (str);
+
+       GetReq(X_StringWidth, 0);
+       req->param.l[0] = font;
+       req->params2 = len;
+       Data (dpy, str, len);
+       if (!_XReply(dpy, &rep))
+           return(0);
+       return(rep.params0);
+}
+
diff --git a/usr/src/new/X/Xlib/XQueryWindow.c b/usr/src/new/X/Xlib/XQueryWindow.c
new file mode 100644 (file)
index 0000000..4cd0737
--- /dev/null
@@ -0,0 +1,29 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XQueryWindow.c,v 10.5 86/04/22 15:27:44 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+Status XQueryWindow (w, info)
+       Window w;
+       register WindowInfo *info;
+{
+       register Display *dpy;
+       register XReq *req;
+       XRep rep;
+
+       GetReq(X_QueryWindow, w);
+
+       if (!_XReply(dpy, &rep))
+           return (0);
+       info->height = rep.params0;
+       info->width = rep.params1;
+       info->x = rep.params2;
+       info->y = rep.params3;
+       info->bdrwidth = rep.params4;
+       info->mapped = rep.param.b[10];
+       info->type = rep.param.b[11];
+       info->assoc_wind = rep.param.l[3];
+       return (1);
+}
+
diff --git a/usr/src/new/X/Xlib/XRaiseWindow.c b/usr/src/new/X/Xlib/XRaiseWindow.c
new file mode 100644 (file)
index 0000000..2cf0558
--- /dev/null
@@ -0,0 +1,15 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XRaiseWindow.c,v 10.5 86/04/22 15:22:23 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XRaiseWindow (w)
+       Window w;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_RaiseWindow, w);
+}
+
diff --git a/usr/src/new/X/Xlib/XReadBitmapF.c b/usr/src/new/X/Xlib/XReadBitmapF.c
new file mode 100644 (file)
index 0000000..c6d364e
--- /dev/null
@@ -0,0 +1,95 @@
+#include <X/mit-copyright.h>
+
+/* Copyright   Massachusetts Institute of Technology  1985 */
+/* $Header: XReadBitmapF.c,v 10.10 86/11/18 11:54:02 jg Rel $ */
+#include "XlibInternal.h"
+#include <stdio.h>
+#include <errno.h>
+#include <strings.h>
+
+#define boolean int
+
+extern int errno;
+
+Status XReadBitmapFile(filename, width, height, data, x_hot, y_hot)
+    char *filename;
+    register int *width, *height;  /* RETURN; must be non-NULL */
+    register short **data;   /* RETURN */
+    int *x_hot, *y_hot;  /* RETURN; may be NULL */
+    {
+    char variable[81];
+    int status, value, i, data_length;
+    FILE *file = fopen (filename, "r");
+
+    if (file == NULL)
+       return (0);
+
+    *width = *height = -1;
+    if (x_hot) *x_hot = -1;
+    if (y_hot) *y_hot = -1;
+    while ((status = fscanf (file, "#define %80s %2d\n", variable, &value))==2)
+       {
+       if (StringEndsWith (variable, "width"))
+           *width = value;
+       else if (StringEndsWith (variable, "height"))
+           *height = value;
+       else if (StringEndsWith (variable, "x_hot")) {
+             if (x_hot) *x_hot = value;
+           }
+       else if (StringEndsWith (variable, "y_hot")) {
+           if (y_hot) *y_hot = value;
+         }
+       }
+
+    if (*width <= 0) {
+       fclose (file);
+       errno = EINVAL;
+       return (-1);
+       }
+       
+    if (*height <= 0) {
+       fclose (file);
+       errno = EINVAL;
+       return (-2);
+       }
+
+    data_length = BitmapSize (*width, *height);
+    *data = (short *) malloc (data_length);
+    data_length /= sizeof(short);
+    if (*data == NULL) {
+       fclose (file);
+       return (-3);
+       }
+    
+    status = fscanf (file, "static short %80s = { 0x%4hx", variable,
+       *data);  /* fills in 0th element of *data array */
+    if ((status != 2) || !StringEndsWith (variable, "bits[]")) {
+       free ((char *)*data);
+       fclose (file);
+       errno = EINVAL;
+       return (-4);
+       }
+
+    for (i=1;i<data_length;i++) {
+       /* fill in i'th element of data array */
+       status = fscanf (file, ", 0x%4hx", *data + i);
+       if (status != 1) {
+           free ((char *)*data);
+           fclose (file);
+           errno = EINVAL;
+           return (-5);
+           }
+       }
+
+    fclose (file);
+    return (1);
+    }
+
+/* StringEndsWith returns TRUE if "s" ends with "suffix", else returns FALSE */
+static boolean StringEndsWith (s, suffix)
+  char *s, *suffix;
+  {
+  int s_len = strlen (s);
+  int suffix_len = strlen (suffix);
+  return (strcmp (s + s_len - suffix_len, suffix) == 0);
+  }
diff --git a/usr/src/new/X/Xlib/XRemoveHost.c b/usr/src/new/X/Xlib/XRemoveHost.c
new file mode 100644 (file)
index 0000000..861eedb
--- /dev/null
@@ -0,0 +1,17 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XRemoveHost.c,v 10.4 86/02/01 15:39:29 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XRemoveHost (host)
+       struct in_addr *host;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_RemoveHost, 0);
+       req->func = XAF_INET;
+       req->param.l[0] = host->s_addr;
+}
+
diff --git a/usr/src/new/X/Xlib/XRemoveNode.c b/usr/src/new/X/Xlib/XRemoveNode.c
new file mode 100644 (file)
index 0000000..e6071fe
--- /dev/null
@@ -0,0 +1,21 @@
+/* $Header: XRemoveNode.c,v 10.2 86/02/01 15:39:31 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+#include "XlibInternal.h"
+#ifdef DNETCONN
+#include <netdnet/dn.h>
+#endif
+XRemoveNode (node)
+       struct dn_naddr *node;
+{
+#ifdef DNETCONN
+       register Display *dpy;
+       register XReq *req;
+       GetReq(X_RemoveHost, 0);
+       req->func = XAF_DECnet;
+       bcopy (node, &(req->param.l[0]), sizeof (struct dn_naddr));
+#endif
+}
diff --git a/usr/src/new/X/Xlib/XRotBuffers.c b/usr/src/new/X/Xlib/XRotBuffers.c
new file mode 100644 (file)
index 0000000..8210bda
--- /dev/null
@@ -0,0 +1,18 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XRotBuffers.c,v 10.4 86/02/01 15:39:34 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+
+
+XRotateBuffers (n)
+       int n;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_RotateCuts, 0);
+       req->func = n;
+}
+
diff --git a/usr/src/new/X/Xlib/XScreenSaver.c b/usr/src/new/X/Xlib/XScreenSaver.c
new file mode 100644 (file)
index 0000000..a24a341
--- /dev/null
@@ -0,0 +1,20 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XScreenSaver.c,v 10.6 86/04/22 15:27:55 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+
+
+XScreenSaver (save_timeout, pattern_timeout, video)
+       int save_timeout, pattern_timeout, video;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_ScreenSaver, 0);
+       req->func = video ? 1 : 0;
+       req->params0 = save_timeout;
+       req->params1 = pattern_timeout;
+}
+
diff --git a/usr/src/new/X/Xlib/XSelectInput.c b/usr/src/new/X/Xlib/XSelectInput.c
new file mode 100644 (file)
index 0000000..0d1da9e
--- /dev/null
@@ -0,0 +1,17 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XSelectInput.c,v 10.5 86/04/22 15:16:52 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XSelectInput (w, mask)
+       Window w;
+       unsigned int mask;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_SelectInput, w);
+       req->param.l[0] = mask;
+}
+
diff --git a/usr/src/new/X/Xlib/XSetDisplay.c b/usr/src/new/X/Xlib/XSetDisplay.c
new file mode 100644 (file)
index 0000000..a3f491d
--- /dev/null
@@ -0,0 +1,18 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XSetDisplay.c,v 10.4 86/02/01 15:39:42 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+
+/* 
+ * XSetDisplay - This proceedure sets the current display (_XlibCurrentDisplay)
+ * with which the library is communicating.
+ */
+XSetDisplay(dpy)
+       register Display *dpy;
+{
+       _XlibCurrentDisplay = dpy;
+}
+
diff --git a/usr/src/new/X/Xlib/XSetIconWind.c b/usr/src/new/X/Xlib/XSetIconWind.c
new file mode 100644 (file)
index 0000000..5b25b0f
--- /dev/null
@@ -0,0 +1,16 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XSetIconWind.c,v 10.4 86/02/01 15:39:45 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XSetIconWindow (w, iw)
+       Window w, iw;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_SetIconWindow, w);
+       req->param.l[0] = iw;
+}
+
diff --git a/usr/src/new/X/Xlib/XSetResHint.c b/usr/src/new/X/Xlib/XSetResHint.c
new file mode 100644 (file)
index 0000000..c8a0227
--- /dev/null
@@ -0,0 +1,21 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XSetResHint.c,v 10.5 86/04/22 15:28:03 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XSetResizeHint (w, width0, height0, widthinc, heightinc)
+       Window w;
+       int width0, widthinc, height0, heightinc;
+
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_SetResizeHint, w);
+       req->params0 = height0;
+       req->params1 = heightinc;
+       req->params2 = width0;
+       req->params3 = widthinc;
+}
+
diff --git a/usr/src/new/X/Xlib/XStippleFill.c b/usr/src/new/X/Xlib/XStippleFill.c
new file mode 100644 (file)
index 0000000..36e13be
--- /dev/null
@@ -0,0 +1,29 @@
+#include <X/mit-copyright.h>
+/* $Header: XStippleFill.c,v 10.2 86/04/22 15:15:05 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+#include "XlibInternal.h"
+XStippleFill (w, x, y, width, height, pixel, stipmask, func, planes)
+       Window w;
+       int x, y;
+       int width, height;
+       int pixel;
+       Bitmap stipmask;
+       int func, planes;
+{
+       register Display *dpy;
+       register XReq *req;
+       GetReq(X_StippleFill, w);
+       req->mask = planes;
+       req->func = func;
+       req->params0 = height;
+       req->params1 = width;
+       req->params2 = x;
+       req->params3 = y;
+       req->paramu4 = pixel;
+       req->param.l[3] = stipmask;
+}
+
diff --git a/usr/src/new/X/Xlib/XStoreBitmap.c b/usr/src/new/X/Xlib/XStoreBitmap.c
new file mode 100644 (file)
index 0000000..3df3a55
--- /dev/null
@@ -0,0 +1,25 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XStoreBitmap.c,v 10.6 86/04/22 15:28:12 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+Bitmap XStoreBitmap (width, height, data)
+       int width, height;
+       short *data;
+{
+       register Display *dpy;
+       register XReq *req;
+       XRep rep;
+       int len;
+
+       GetReq(X_StoreBitmap, 0);
+       req->params0 = height;
+       req->params1 = width;
+       len = BitmapSize (width, height)/UBPS;
+       PackData(dpy, data, len);
+       if (!_XReply(dpy, &rep))
+           return(NULL);
+       return (rep.param.l[0]);
+}
+
diff --git a/usr/src/new/X/Xlib/XStoreBuffer.c b/usr/src/new/X/Xlib/XStoreBuffer.c
new file mode 100644 (file)
index 0000000..df7bc41
--- /dev/null
@@ -0,0 +1,20 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XStoreBuffer.c,v 10.5 86/04/22 15:28:09 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XStoreBuffer (str, nbytes, buffer)
+
+       char *str;
+       int nbytes;
+{
+       register XReq *req;
+       register Display *dpy;
+
+       GetReq(X_StoreBytes, 0);
+       req->params0 = nbytes;
+       req->func = buffer;
+       Data(dpy, str, nbytes);
+}
+
diff --git a/usr/src/new/X/Xlib/XStoreBytes.c b/usr/src/new/X/Xlib/XStoreBytes.c
new file mode 100644 (file)
index 0000000..b04a1d2
--- /dev/null
@@ -0,0 +1,20 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XStoreBytes.c,v 10.5 86/04/22 15:28:34 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XStoreBytes (str, length)
+
+       char *str;
+       int length;
+{
+       register XReq *req;
+       register Display *dpy;
+
+       GetReq(X_StoreBytes, 0);
+       req->params0 = length;
+       req->func = 0;  /* cut buffer number 0 */
+       Data(dpy, str, length);
+}
+
diff --git a/usr/src/new/X/Xlib/XStoreColor.c b/usr/src/new/X/Xlib/XStoreColor.c
new file mode 100644 (file)
index 0000000..3d4c4a9
--- /dev/null
@@ -0,0 +1,26 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XStoreColor.c,v 10.5 86/04/22 15:25:49 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XStoreColor (def)
+       register Color *def;
+{
+       register Display *dpy;
+       register XReq *req;
+       ColorDef proto_def;
+       GetReq (X_StoreColors, 0);
+       req->params0 = 1;  /* just one color to store */
+       
+       /* Color structure in library uses int for pixel,
+          but protocol's ColorDef wants a short;
+          thus, data must be copied */
+
+        proto_def.pixel = def->pixel;
+       proto_def.red = def->red;
+       proto_def.green = def->green;   
+       proto_def.blue = def->blue;
+
+       Data (dpy, (char *)&proto_def, sizeof (ColorDef));
+}
diff --git a/usr/src/new/X/Xlib/XStoreColors.c b/usr/src/new/X/Xlib/XStoreColors.c
new file mode 100644 (file)
index 0000000..c8d584b
--- /dev/null
@@ -0,0 +1,32 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XStoreColors.c,v 10.5 86/04/22 15:25:11 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XStoreColors (ncolors, defs)
+       int ncolors;
+       register Color *defs;
+{
+       register Display *dpy;
+       register XReq *req;
+       GetReq (X_StoreColors, 0);
+       req->params0 = ncolors;
+
+       /* Color structure in library uses int for pixel,
+          but protocol's ColorDef wants a short;
+          thus, data must be copied */
+        {
+       int nbytes = ncolors*sizeof(ColorDef);
+       register int i;
+       register ColorDef *proto_defs = (ColorDef *) malloc (nbytes);
+       for (i=0;i<ncolors;i++) {
+           proto_defs[i].pixel = defs[i].pixel;
+           proto_defs[i].red = defs[i].red;
+           proto_defs[i].green = defs[i].green;
+           proto_defs[i].blue = defs[i].blue;
+           }
+       Data (dpy, (char *)proto_defs, nbytes);
+       free ((char *)proto_defs);
+       }
+}
diff --git a/usr/src/new/X/Xlib/XStoreCursor.c b/usr/src/new/X/Xlib/XStoreCursor.c
new file mode 100644 (file)
index 0000000..40d4e0e
--- /dev/null
@@ -0,0 +1,30 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XStoreCursor.c,v 10.5 86/04/22 15:29:29 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+Cursor XStoreCursor (cbitmap, mbitmap, xOffset, yOffset,
+    foreground, background, func)
+       Bitmap cbitmap, mbitmap;
+       int xOffset, yOffset;
+       int func;
+       int foreground, background;
+{
+       register Display *dpy;
+       register XReq *req;
+       XRep rep;
+
+       GetReq(X_StoreCursor, 0);
+       req->func = func;
+       req->param.l[0] = cbitmap;
+       req->paramu2 = foreground;
+       req->paramu3 = background;
+       req->param.l[2] = mbitmap;
+       req->params6 = xOffset;
+       req->params7 = yOffset;
+       if (!_XReply (dpy, &rep))
+           return (NULL);
+       return (rep.param.l[0]);
+}
+
diff --git a/usr/src/new/X/Xlib/XStoreName.c b/usr/src/new/X/Xlib/XStoreName.c
new file mode 100644 (file)
index 0000000..750413d
--- /dev/null
@@ -0,0 +1,19 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XStoreName.c,v 10.5 86/04/22 15:30:11 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XStoreName (w, name)
+       Window w;
+       char *name;
+{
+       register Display *dpy;
+       register XReq *req;
+       int len;
+
+       GetReq(X_StoreName, w);
+       len = req->params0 = strlen(name);
+       Data(dpy, name, len);
+}
+
diff --git a/usr/src/new/X/Xlib/XStorePixXY.c b/usr/src/new/X/Xlib/XStorePixXY.c
new file mode 100644 (file)
index 0000000..d260e4e
--- /dev/null
@@ -0,0 +1,26 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XStorePixXY.c,v 10.6 86/04/22 15:26:55 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+Pixmap XStorePixmapXY (width, height, data)
+       int width, height;
+       short *data;
+{
+       register Display *dpy;
+       register XReq *req;
+       XRep rep;
+       int len;
+
+       GetReq(X_StorePixmap, 0);
+       req->func = XYFormat;
+       req->params0 = height;
+       req->params1 = width;
+       len = XYPixmapSize (width, height, dpy->dplanes);
+       PackData(dpy, data, len);
+       if (!_XReply(dpy, &rep))
+           return(NULL);
+       return (rep.param.l[0]);
+}
+
diff --git a/usr/src/new/X/Xlib/XStorePixmapZ.c b/usr/src/new/X/Xlib/XStorePixmapZ.c
new file mode 100644 (file)
index 0000000..d37a468
--- /dev/null
@@ -0,0 +1,28 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XStorePixmapZ.c,v 10.5 86/04/22 15:30:48 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+Pixmap XStorePixmapZ (width, height, data)
+       int width, height;
+       caddr_t data;
+{
+       register Display *dpy;
+       register XReq *req;
+       XRep rep;
+       int len;
+
+       GetReq(X_StorePixmap, 0);
+       req->func = ZFormat;
+       req->params0 = height;
+       req->params1 = width;
+       len = (dpy->dplanes > 8)
+         ? WZPixmapSize (width, height)
+         : BZPixmapSize (width, height);
+       Data (dpy, data, len);
+       if (!_XReply(dpy, &rep))
+           return(NULL);
+       return (rep.param.l[0]);
+}
+
diff --git a/usr/src/new/X/Xlib/XStringWidth.c b/usr/src/new/X/Xlib/XStringWidth.c
new file mode 100644 (file)
index 0000000..1e6da17
--- /dev/null
@@ -0,0 +1,48 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XStringWidth.c,v 10.4 86/02/01 15:40:32 tony Rel $ */
+/* Copyright Massachusetts Institute of Technology 1985 */
+
+#include "XlibInternal.h"
+int XStringWidth (string, info, charpad, spacepad)
+    register char *string;
+    register FontInfo *info;
+    register int charpad, spacepad;
+    {
+    register int result = 0;
+    if (!*string)  /* zero length string */
+       return (0);
+
+    if (info->fixedwidth) {
+       int length = strlen (string);
+       result = length * (info->width + charpad) - charpad;
+           /* don't pad last character */
+       if (spacepad) {
+           char *sub = string, *index();
+           while (sub = index (sub, ' ')) {
+               result += spacepad;
+               sub++;
+               }
+           if (string[length-1] == ' ')
+               result -= spacepad;
+               /* don't pad terminating space character */
+           }
+       }
+
+    else {   /* variable width font */
+       unsigned char c;
+       register short *widths = info->widths - info->firstchar;
+       while (c = *(string++)) {
+           if ((c >= info->firstchar) && (c <= info->lastchar))
+               result += (widths[c] + charpad);
+           if (c == ' ')
+               result += spacepad;
+           }
+       result -= charpad;  /* don't pad last character */
+       if (*(string-1) == ' ')
+           result -= spacepad;
+           /* don't pad terminating space character */
+       }
+
+    return (result);
+    }
diff --git a/usr/src/new/X/Xlib/XSync.c b/usr/src/new/X/Xlib/XSync.c
new file mode 100644 (file)
index 0000000..2a68362
--- /dev/null
@@ -0,0 +1,27 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XSync.c,v 10.4 86/02/01 15:40:36 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+
+extern _QEvent *_qfree;
+
+/* Synchronize with errors and events, optionally discarding pending events. */
+
+XSync (discard)
+       int discard;  /* 0 or 1 */
+{      
+       register Display *dpy;
+       register XReq *req;
+       XRep rep;
+       GetReq (X_SetUp, 0);
+       _XReply(dpy, &rep);
+       if (discard && dpy->head) {
+           dpy->tail->next = _qfree;
+           _qfree = dpy->head;
+           dpy->head = dpy->tail = NULL;
+           dpy->qlen = 0;
+           }
+}
+
diff --git a/usr/src/new/X/Xlib/XText.c b/usr/src/new/X/Xlib/XText.c
new file mode 100644 (file)
index 0000000..26b300f
--- /dev/null
@@ -0,0 +1,30 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XText.c,v 10.5 86/04/22 15:30:59 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XText (w, x, y, str, len, font, foreground, background)
+       Window w;
+       int x, y, len;
+       char *str;
+       Font font;
+       int foreground, background;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_Text, w);
+       req->func = GXcopy;
+       req->mask = ~0;  /* all planes */
+       req->params0 = x;
+       req->params1 = y;
+       req->param.l[1] = font;
+       req->paramu4 = foreground;
+       req->paramu5 = background;
+       req->params6 = len;
+       req->param.b[14] = 0;  /* no char pad */
+       req->param.b[15] = 0;  /* no space pad */
+       Data(dpy, str, len);
+}
+
diff --git a/usr/src/new/X/Xlib/XTextMask.c b/usr/src/new/X/Xlib/XTextMask.c
new file mode 100644 (file)
index 0000000..52fcacf
--- /dev/null
@@ -0,0 +1,29 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XTextMask.c,v 10.5 86/04/22 15:32:09 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XTextMask (w, x, y, str, len, font, source)
+       Window w;
+       int x, y, len;
+       char *str;
+       Font font;
+       int source;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_TextMask, w);
+       req->func = GXcopy;
+       req->mask = ~0;  /* all planes */
+       req->params0 = x;
+       req->params1 = y;
+       req->param.l[1] = font;
+       req->paramu4 = source;
+       req->params6 = len;
+       req->param.b[14] = 0;  /* no character pad */
+       req->param.b[15] = 0;  /* no space pad */
+       Data(dpy, str, len);
+}
+
diff --git a/usr/src/new/X/Xlib/XTextMaskPad.c b/usr/src/new/X/Xlib/XTextMaskPad.c
new file mode 100644 (file)
index 0000000..24bba01
--- /dev/null
@@ -0,0 +1,31 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XTextMaskPad.c,v 10.4 86/02/01 15:40:50 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XTextMaskPad (w, x, y, str, len, font, 
+   charpad, spacepad, source, func, planes)
+       Window w;
+       int x, y, len;
+       char *str;
+       Font font;
+       int source;
+       int func, planes, charpad, spacepad;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_TextMask, w);
+       req->func = func;
+       req->mask = planes;
+       req->param.s[0] = x;
+       req->param.s[1] = y;
+       req->param.l[1] = font;
+       req->param.u[4] = source;
+       req->param.s[6] = len;
+       req->param.b[14] = charpad;
+       req->param.b[15] = spacepad;
+       Data(dpy, str, len);
+}
+
diff --git a/usr/src/new/X/Xlib/XTextPad.c b/usr/src/new/X/Xlib/XTextPad.c
new file mode 100644 (file)
index 0000000..b28cee9
--- /dev/null
@@ -0,0 +1,33 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XTextPad.c,v 10.4 86/02/01 15:40:53 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XTextPad (w, x, y, str, len, font,
+   charpad, spacepad, foreground, background, func, planes)
+       Window w;
+       int func, planes;
+       int charpad, spacepad;
+       int x, y, len;
+       char *str;
+       Font font;
+       int foreground, background;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_Text, w);
+       req->func = func;
+       req->mask = planes;
+       req->param.s[0] = x;
+       req->param.s[1] = y;
+       req->param.l[1] = font;
+       req->param.u[4] = foreground;
+       req->param.u[5] = background;
+       req->param.s[6] = len;
+       req->param.b[14] = charpad;
+       req->param.b[15] = spacepad;
+       Data(dpy, str, len);
+}
+
diff --git a/usr/src/new/X/Xlib/XTileAbsolute.c b/usr/src/new/X/Xlib/XTileAbsolute.c
new file mode 100644 (file)
index 0000000..ea889f5
--- /dev/null
@@ -0,0 +1,16 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XTileAbsolute.c,v 10.4 86/02/01 15:41:01 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XTileAbsolute (w)
+       Window w;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_TileMode, w);
+       req->func = TileModeAbsolute;
+}
+
diff --git a/usr/src/new/X/Xlib/XTileFill.c b/usr/src/new/X/Xlib/XTileFill.c
new file mode 100644 (file)
index 0000000..6dac28a
--- /dev/null
@@ -0,0 +1,28 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XTileFill.c,v 10.4 86/02/01 15:41:05 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XTileFill (w, x, y, width, height, tile, clipmask, func, planes)
+       Window w;
+       int x, y;
+       int width, height;
+       Pixmap tile;
+       Bitmap clipmask;
+       int func, planes;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_TileFill, w);
+       req->mask = planes;
+       req->func = func;
+       req->param.s[0] = height;
+       req->param.s[1] = width;
+       req->param.s[2] = x;
+       req->param.s[3] = y;
+       req->param.l[2] = tile;
+       req->param.l[3] = clipmask;
+}
+
diff --git a/usr/src/new/X/Xlib/XTileRelative.c b/usr/src/new/X/Xlib/XTileRelative.c
new file mode 100644 (file)
index 0000000..887dfdc
--- /dev/null
@@ -0,0 +1,16 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XTileRelative.c,v 10.4 86/02/01 15:41:08 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XTileRelative (w)
+       Window w;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_TileMode, w);
+       req->func = TileModeRelative;
+}
+
diff --git a/usr/src/new/X/Xlib/XTileSet.c b/usr/src/new/X/Xlib/XTileSet.c
new file mode 100644 (file)
index 0000000..980b3ac
--- /dev/null
@@ -0,0 +1,26 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XTileSet.c,v 10.4 86/02/01 15:41:11 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XTileSet (w, x, y, width, height, tile)
+       Window w;
+       int x, y;
+       int width, height;
+       Pixmap tile;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_TileFill, w);
+       req->mask = ~0;  /* all planes */
+       req->func = GXcopy;
+       req->param.s[0] = height;
+       req->param.s[1] = width;
+       req->param.s[2] = x;
+       req->param.s[3] = y;
+       req->param.l[2] = tile;
+       req->param.l[3] = 0;  /* no clip mask */
+}
+
diff --git a/usr/src/new/X/Xlib/XUndefCursor.c b/usr/src/new/X/Xlib/XUndefCursor.c
new file mode 100644 (file)
index 0000000..e374819
--- /dev/null
@@ -0,0 +1,15 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XUndefCursor.c,v 10.4 86/02/01 15:41:14 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XUndefineCursor (w)
+       Window w;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_DefineCursor, w);
+       req->param.l[0] = 0;
+}
diff --git a/usr/src/new/X/Xlib/XUngrabButton.c b/usr/src/new/X/Xlib/XUngrabButton.c
new file mode 100644 (file)
index 0000000..4c85a68
--- /dev/null
@@ -0,0 +1,16 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XUngrabButton.c,v 10.4 86/02/01 15:41:18 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XUngrabButton (mask)
+       int mask;
+{
+       register XReq *req;
+       register Display *dpy;
+
+       GetReq(X_UngrabButton, 0);
+       req->mask = mask;
+}
+
diff --git a/usr/src/new/X/Xlib/XUngrabMouse.c b/usr/src/new/X/Xlib/XUngrabMouse.c
new file mode 100644 (file)
index 0000000..7644d28
--- /dev/null
@@ -0,0 +1,14 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XUngrabMouse.c,v 10.4 86/02/01 15:41:22 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XUngrabMouse ()
+{
+       register XReq *req;
+       register Display *dpy;
+
+       GetReq(X_UngrabMouse, 0);
+}
+
diff --git a/usr/src/new/X/Xlib/XUngrabServer.c b/usr/src/new/X/Xlib/XUngrabServer.c
new file mode 100644 (file)
index 0000000..2d74db6
--- /dev/null
@@ -0,0 +1,14 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XUngrabServer.c,v 10.4 86/02/01 15:41:25 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XUngrabServer ()
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_UngrabServer, 0);
+}
+
diff --git a/usr/src/new/X/Xlib/XUnmapSubs.c b/usr/src/new/X/Xlib/XUnmapSubs.c
new file mode 100644 (file)
index 0000000..0bf919a
--- /dev/null
@@ -0,0 +1,15 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XUnmapSubs.c,v 10.4 86/02/01 15:41:30 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XUnmapSubwindows (w)
+       Window w;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_UnmapSubwindows, w);
+}
+
diff --git a/usr/src/new/X/Xlib/XUnmapTrans.c b/usr/src/new/X/Xlib/XUnmapTrans.c
new file mode 100644 (file)
index 0000000..bc5a648
--- /dev/null
@@ -0,0 +1,15 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XUnmapTrans.c,v 10.5 86/04/22 15:31:02 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XUnmapTransparent (w)
+       Window w;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_UnmapTransparent, w);
+}
+
diff --git a/usr/src/new/X/Xlib/XUnmapWindow.c b/usr/src/new/X/Xlib/XUnmapWindow.c
new file mode 100644 (file)
index 0000000..724b677
--- /dev/null
@@ -0,0 +1,15 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XUnmapWindow.c,v 10.4 86/02/01 15:41:35 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XUnmapWindow (w)
+       Window w;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_UnmapWindow, w);
+}
+
diff --git a/usr/src/new/X/Xlib/XUpdateMouse.c b/usr/src/new/X/Xlib/XUpdateMouse.c
new file mode 100644 (file)
index 0000000..c3aa2d3
--- /dev/null
@@ -0,0 +1,43 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XUpdateMouse.c,v 10.4 86/02/01 15:41:37 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+
+extern _QEvent *_qfree;
+
+/* Like XQueryMouse, but also reads pending events and flushes any MouseMoved
+ * events at the head of the queue.  A good way to track the mouse is to use
+ * a MouseMoved event as a "hint", by calling this routine to get up to date
+ * coordinates.
+ */
+
+Status XUpdateMouse (w, x, y, subw)
+       Window w;
+       Window *subw;
+       int *x, *y;
+{
+       register Display *dpy;
+       register XReq *req;
+       register _QEvent *qelt;
+       XRep rep;
+
+       XPending(dpy = _XlibCurrentDisplay);
+           /* read all events in socket's kernel buffer */
+       GetReq(X_QueryMouse, w);
+       if (!_XReply(dpy, &rep))
+           return(0);
+       while ((qelt = dpy->head) && qelt->event.type == MouseMoved) {
+           if ((dpy->head = qelt->next) == NULL)
+               dpy->tail = NULL;
+           qelt->next = _qfree;
+           _qfree = qelt;
+           dpy->qlen--;
+       }
+       *x = rep.param.s[2];
+       *y = rep.param.s[3];
+       *subw = rep.param.l[0];
+       return (1);
+}
+
diff --git a/usr/src/new/X/Xlib/XWarpCond.c b/usr/src/new/X/Xlib/XWarpCond.c
new file mode 100644 (file)
index 0000000..5a6a8b7
--- /dev/null
@@ -0,0 +1,23 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XWarpCond.c,v 10.5 86/04/22 15:16:06 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XCondWarpMouse (dw, x, y, sw, left, top, width, height)
+       Window dw, sw;
+       int x, y, left, top, width, height;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_WarpMouse, dw);
+       req->params0 = x;
+       req->params1 = y;
+       req->param.l[1] = sw;
+       req->params4 = height;
+       req->params5 = width;
+       req->params6 = left;
+       req->params7 = top;
+}
+
diff --git a/usr/src/new/X/Xlib/XWarpMouse.c b/usr/src/new/X/Xlib/XWarpMouse.c
new file mode 100644 (file)
index 0000000..4287c7a
--- /dev/null
@@ -0,0 +1,23 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XWarpMouse.c,v 10.7 86/04/22 15:16:49 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+XWarpMouse (w, x, y)
+       Window w;
+       int x, y;
+{
+       register Display *dpy;
+       register XReq *req;
+
+       GetReq(X_WarpMouse, w);
+       req->params0 = x;
+       req->params1 = y;
+       req->param.l[1] = RootWindow;
+       req->params4 = 0;
+       req->params5 = 0;
+       req->params6 = 0;
+       req->params7 = 0;
+}
+
diff --git a/usr/src/new/X/Xlib/XWindowEvent.c b/usr/src/new/X/Xlib/XWindowEvent.c
new file mode 100644 (file)
index 0000000..5a79e4d
--- /dev/null
@@ -0,0 +1,54 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XWindowEvent.c,v 10.5 86/04/22 15:21:13 jg Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include "XlibInternal.h"
+
+extern _QEvent *_qfree;
+
+/* 
+ * Flush output and (wait for and) return the next event in the queue
+ * for the given window matching one of the events in the mask.
+ * Events earlier in the queue are not discarded.
+ */
+
+XWindowEvent (w, mask, event)
+       Window w;               /* Selected window. */
+       int mask;               /* Selected event mask. */
+       register XEvent *event; /* XEvent to be filled in. */
+{
+       register Display *dpy;
+       register _QEvent *prev, *qelt;
+
+       dpy = _XlibCurrentDisplay;
+       _XFlush (dpy);
+       for (prev = NULL, qelt = dpy->head;
+            qelt && (qelt->event.window != w ||
+                     !(qelt->event.type & mask));
+            qelt = (prev = qelt)->next) ;
+       if (qelt) {
+           *event = qelt->event;
+           if (prev) {
+               if ((prev->next = qelt->next) == NULL)
+                   dpy->tail = prev;
+           } else {
+               if ((dpy->head = qelt->next) == NULL)
+                   dpy->tail = NULL;
+           }
+           qelt->next = _qfree;
+           _qfree = qelt;
+           dpy->qlen--;
+           return;
+       }
+       while (1) {
+           _XRead (dpy, (char *)event, sizeof(XEvent));
+           if (event->type == X_Error)
+               _XError(dpy, (XErrorEvent *)event);
+           else if ((event->window == w) && (event->type & mask))
+               return;
+           else
+               _XEnq(dpy, event);
+       }
+}
+
diff --git a/usr/src/new/X/Xlib/Xdefault.h b/usr/src/new/X/Xlib/Xdefault.h
new file mode 100644 (file)
index 0000000..b7691b8
--- /dev/null
@@ -0,0 +1,10 @@
+#ifdef KEYBD
+       /*
+        * This is the directory where keyboard mapping can be found
+        */
+#define        KEYBDDIR        "/lib/X/keybd/"
+#endif KEYBD
+       /*
+        * This is the default Xdefaults file
+        */
+#define        XDEFAULTS       "/lib/X/Xdefaults"
diff --git a/usr/src/new/X/Xlib/Xkeyboard.h b/usr/src/new/X/Xlib/Xkeyboard.h
new file mode 100644 (file)
index 0000000..10a18f8
--- /dev/null
@@ -0,0 +1,94 @@
+#include <X/mit-copyright.h>
+
+/* $Header: Xkeyboard.h,v 10.4 86/02/01 15:41:50 tony Rel $ */
+/* Copyright 1985, Massachusetts Institute of Technology */
+/*
+ * This file is useful for dealing with key events independent of any
+ * ascii mapping.
+ */
+
+#define KC_F1  0126
+#define KC_F2  0127
+#define KC_F3  0130
+#define KC_F4  0131
+#define KC_F5  0132
+
+#define KC_F6  0144
+#define KC_F7  0145
+#define KC_F8  0146
+#define KC_F9  0147
+#define KC_F10         0150
+
+#define KC_F11         0161
+#define KC_ESC  0161  /* escape: same as F11 */
+
+#define KC_F12         0162  
+#define KC_BS   0162  /* backspace: same as F12 */
+
+#define KC_F13  0163
+#define KC_LF   0163  /* line feed: same as F13 */
+#define KC_F14         0164
+
+#define KC_F15         0174
+#define KC_F16         0175
+
+#define KC_F17         0200
+#define KC_F18         0201
+#define KC_F19         0202
+#define KC_F20         0203
+
+#define KC_E1          0212
+#define KC_E2  0213
+#define KC_E3  0214
+#define KC_E4  0215
+#define KC_E5  0216
+#define KC_E6  0217
+
+#define KC_KEYPAD_0 0222
+#define KC_KEYPAD_PERIOD    0224
+#define KC_ENTER    0225
+#define KC_KEYPAD_1 0226
+#define KC_KEYPAD_2 0227
+#define KC_KEYPAD_3 0230
+#define KC_KEYPAD_4 0231
+#define KC_KEYPAD_5 0232
+#define KC_KEYPAD_6 0233
+#define KC_KEYPAD_COMMA            0234
+#define KC_KEYPAD_7 0235
+#define KC_KEYPAD_8 0236
+#define KC_KEYPAD_9 0237
+#define KC_KEYPAD_MINUS            0240
+
+#define KC_PF1 0241
+#define KC_PF2 0242
+#define KC_PF3 0243
+#define KC_PF4 0244
+
+#define KC_SHIFT 0256
+#define KC_CTRL         0257
+#define KC_LOCK  0260
+#define KC_SYMBOL 0261
+#define KC_META   0261  /* same as KC_SYMBOL */
+
+#define KC_CURSOR_LEFT 0247
+#define KC_CURSOR_RIGHT 0250
+#define KC_CURSOR_DOWN 0251
+#define KC_CURSOR_UP   0252
+
+#define IsShiftKey(code) \
+    (((unsigned)code)>=KC_SHIFT && ((unsigned)code)<=KC_META)
+
+#define IsCursorKey(code) \
+    (((unsigned)code)>=KC_CURSOR_LEFT && ((unsigned)code)<=KC_CURSOR_UP)
+
+#define IsKeypadKey(code) \
+    (((unsigned)code)>=KC_KEYPAD_0 && ((unsigned)code)<=KC_KEYPAD_MINUS)
+
+#define IsFunctionKey(code) \
+    (((unsigned)code)>=KC_F1 && ((unsigned)code)<=KC_E6)
+
+#define IsPFKey(code) \
+    (((unsigned)code)>=KC_PF1 && ((unsigned)code)<=KC_PF4)
+
+#define IsTypewriterKey(code) \
+    (((unsigned)code)>=0274 && ((unsigned)code)<=0373)
diff --git a/usr/src/new/X/Xlib/Xkeymap.h b/usr/src/new/X/Xlib/Xkeymap.h
new file mode 100644 (file)
index 0000000..97f2b1e
--- /dev/null
@@ -0,0 +1,37 @@
+#include <X/mit-copyright.h>
+
+/* $Header: Xkeymap.h,v 10.5 86/02/01 15:41:53 tony Rel $ */
+/* Copyright 1985, Massachusetts Institute of Technology */
+
+#define X_KEYMAP_MAGIC 0372  /* magic number which must be first byte
+                               of a keymap file */
+
+/* KeyMap: contains single-byte character bindings, or indications
+   that a keycode is actually bound in the extension or runtime table */
+
+typedef unsigned char KeyMapElt [16];
+
+#define UNBOUND (unsigned char)'\377'
+#define EXTENSION_BOUND (unsigned char)'\376'
+#define RUNTIME_TABLE_BOUND (unsigned char)'\375'
+#define SingleCharBound(c) ((unsigned char)c < (unsigned char)'\375')
+
+/* Extension: contains multiple-byte character bindings from
+   the keymap file.  Not modified at runtime.  */
+
+typedef struct {
+    unsigned char keycode;
+    unsigned char metabits;
+    unsigned char length;
+    } ExtensionHeader;
+
+#define ExtensionHeaderSize 3
+    /* since sizeof (ExtensionHeader) is 4 on some machines, e.g. Sun */
+
+/* macro used to iterate through the extension */
+#define NextExtension(this) \
+  this = (ExtensionHeader *) ((char *)this + ExtensionHeaderSize + this->length)
+
+#define DontCareMetaBits 0377
+  /* appears in extension whenever the binding applies to all possible
+     combinations of shift/lock/meta/control keys */
diff --git a/usr/src/new/X/Xlib/XlibInternal.c b/usr/src/new/X/Xlib/XlibInternal.c
new file mode 100644 (file)
index 0000000..431dcfd
--- /dev/null
@@ -0,0 +1,397 @@
+#include <X/mit-copyright.h>
+
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+/*
+ *     XlibInternal.c - Internal support routines for the C subroutine
+ *     interface library (Xlib) to the X Window System Protocol V8.0.
+ */
+
+#include "XlibInternal.h"
+#include <sys/uio.h>
+
+/*
+ * The following routines are internal routines used by Xlib for protocol
+ * packet transmission and reception.
+ *
+ * XIOError(Display *) will be called if any sort of system call error occurs.
+ * This is assumed to be a fatal condition, i.e., XIOError should not return.
+ *
+ * XError(Display *, XErrorEvent *) will be called whenever an X_Error event is
+ * received.  This is not assumed to be a fatal condition, i.e., it is
+ * acceptable for this procedure to return.  However, XError should NOT
+ * perform any operations (directly or indirectly) on the DISPLAY.
+ *
+ * Routines declared with a return type of 'Status' return 0 on failure,
+ * and non 0 on success.  Routines with no declared return type don't 
+ * return anything.  Whenever possible routines that create objects return
+ * the object they have created.
+ */
+
+#ifndef lint
+static char rcsid[] = "$Header: XlibInternal.c,v 10.13 86/04/22 15:30:52 jg Rel $";
+#endif
+
+#ifdef titan
+#define iovbase iov_base.saddr
+#else
+#define iovbase iov_base
+#endif
+Display *_XlibCurrentDisplay = NULL;   /* default display to use in library */
+_QEvent *_qfree = NULL;                        /* NULL _QEvent. */
+
+static int padlength[4] = {0, 3, 2, 1};
+    /* lookup table for adding padding bytes to data that is read from
+       or written to the X socket.  */
+
+/*
+ * _XFlush - Flush the X request buffer.  If the buffer is empty, no
+ * action is taken.  This routine correctly handles incremental writes.
+ */
+_XFlush (dpy)
+       register Display *dpy;
+{
+       register int size;
+       register int write_stat;
+       register char *bufindex;
+
+       size = dpy->bufptr - dpy->buffer;
+       bufindex = dpy->bufptr = dpy->buffer;
+       /*
+        * While write has not written the entire buffer, keep looping
+        * untill the entire buffer is written.  bufindex will be incremented
+        * and size decremented as buffer is written out.
+        */
+       while (size) {
+               if ((write_stat = write(dpy->fd, bufindex, size)) == -1) {
+                       /* Write failed! */
+                       /* errno set by write system call. */
+                       _XIOError(dpy);
+               }
+               size -= write_stat;
+               bufindex += write_stat;
+       }
+       dpy->lastdraw = NULL;
+}
+
+
+/* 
+ * _XRead - Read bytes from the socket taking into account incomplete
+ * reads.
+ */
+_XRead (dpy, data, size)
+       register Display *dpy;
+       register char *data;
+       register int size;
+{
+       register int bytes_read;
+
+       while ((bytes_read = read(dpy->fd, data, size)) != size) {
+
+               if (bytes_read > 0) {
+                   size -= bytes_read;
+                   data += bytes_read;
+                   }
+
+               else if (bytes_read == 0) {
+                   /* Read failed because of end of file! */
+                   errno = EPIPE;
+                   _XIOError(dpy);
+                   }
+
+               else  /* bytes_read is less than 0; presumably -1 */ {
+                   /* If it's a system call interrupt, it's not an error. */
+                   if (errno != EINTR)
+                       _XIOError(dpy);
+                   }
+                }
+}
+
+/*
+ * _XReadPad - Read bytes from the socket taking into account incomplete
+ * reads.  If the number of bytes is not 0 mod 32, read additional pad
+ * bytes.
+ */
+_XReadPad (dpy, data, size)
+       register Display *dpy;  
+       register char *data;
+       register int size;
+{
+       register int bytes_read;
+       struct iovec iov[2];
+       char pad[3];
+
+       iov[0].iov_len = size;
+       iov[0].iovbase = data;
+       /* 
+        * The following hack is used to provide 32 bit long-word
+        * aligned padding.  The [1] vector is of length 0, 1, 2, or 3,
+        * whatever is needed.
+        */
+
+       iov[1].iov_len = padlength[size & 3];
+       iov[1].iovbase = pad;
+       size += iov[1].iov_len;
+
+       while ((bytes_read = readv (dpy->fd, iov, 2)) != size) {
+
+           if (bytes_read > 0) {
+               size -= bytes_read;
+               if ((iov[0].iov_len -= bytes_read) < 0) {
+                   iov[1].iov_len += iov[0].iov_len;
+                   iov[1].iovbase -= iov[0].iov_len;
+                   iov[0].iov_len = 0;
+                   }
+               else
+                   iov[0].iovbase += bytes_read;
+               }
+
+           else if (bytes_read == 0) {
+               /* Read failed because of end of file! */
+               errno = EPIPE;
+               _XIOError(dpy);
+               }
+           
+           else  /* bytes_read is less than 0; presumably -1 */ {
+               /* If it's a system call interrupt, it's not an error. */
+               if (errno != EINTR)
+                   _XIOError(dpy);
+               }
+           }
+
+}
+
+/*
+ * _XSend - Flush the buffer and send the client data. 32 bit word aligned
+ * transmission is used, if size is not 0 mod 4, extra bytes are transmitted.
+ */
+_XSend (dpy, data, size)
+       register Display *dpy;
+       char *data;
+       register int size;
+{
+       register int len;
+       struct iovec iov[3];
+       char pad[3];
+
+       iov[0].iov_len = len = dpy->bufptr - dpy->buffer;
+       iov[0].iovbase = dpy->bufptr = dpy->buffer;
+       iov[1].iov_len = size;
+       iov[1].iovbase = data;
+       /* 
+        * The following hack is used to provide 32 bit long-word
+        * aligned padding.  The [2] vector is of length 0, 1, 2, or 3,
+        * whatever is needed.
+        */
+       iov[2].iov_len = padlength[size & 3];
+       iov[2].iovbase = pad;
+       len += (size + 3) & ~3;
+       /*
+        * Use while to allow for incremental writes.
+        */
+       while ((size = writev(dpy->fd, iov, 3)) != len) {
+               if (size < 0) _XIOError(dpy);
+               len -= size;
+               if ((iov[0].iov_len -= size) < 0) {
+                   iov[1].iov_len += iov[0].iov_len;
+                   iov[1].iovbase -= iov[0].iov_len;
+                   iov[0].iov_len = 0;
+                   if (iov[1].iov_len < 0) {
+                       iov[2].iov_len += iov[1].iov_len;
+                       iov[2].iovbase -= iov[1].iov_len;
+                       iov[1].iov_len = 0;
+                   }
+               }
+               else {
+                       iov[0].iovbase += size;
+               }
+       }
+       dpy->lastdraw = NULL;
+}
+
+/*
+ * _XReply - Wait for a reply packet and copy its contents into the
+ * specified rep.  Mean while we must handle error and event packets that
+ * we may encounter.
+ */
+Status _XReply (dpy, rep)
+    register Display *dpy;
+    register XRep *rep;
+{
+    _XFlush(dpy);
+    while (1) {
+       _XRead(dpy, (char *)rep, sizeof(XRep));
+       switch ((int)rep->code) {
+
+           case X_Reply:
+               /* Reply recieved. */
+               return(1);
+                
+           case X_Error:
+               {
+               /* X_Error packet encountered! */
+               int current_request = dpy->request;
+               XErrorEvent *error = (XErrorEvent *) rep;
+
+               if (error->serial == current_request)
+                       /* do not die on "no such font", "can't allocate",
+                          "can't grab" failures */
+                       switch (error->error_code) {
+                       case BadFont:
+                               if (error->request_code != X_GetFont)
+                                       break;
+                       case BadAlloc:
+                       case BadColor:
+                       case BadGrab:
+                               return (0);
+                       }
+               _XError(dpy, error);
+               if (error->serial == current_request)
+                   return(0);
+               }
+               break;
+           default:
+               _XEnq(dpy, (XEvent *) rep);
+               break;
+           }
+       }
+}   
+
+
+/*
+ * _XEnq - Place event packets on the display's queue.
+ */
+_XEnq (dpy, event)
+       register Display *dpy;
+       register XEvent *event;
+{
+       register _QEvent *qelt;
+       extern char *malloc();
+
+       if (
+               /* If we are squishing MouseMoved events AND ... */
+               dpy->squish && 
+               /* the current event is a MouseMoved event AND ... */
+               (event->type == MouseMoved) &&
+               /* if there is a last event on the display queue AND ... */
+               (qelt = dpy->tail) && 
+               /* if that last event is also a MouseMoved event AND ... */
+               (qelt->event.type == MouseMoved) &&
+               /* it has the same event window as the current event ... */
+               (event->window == qelt->event.window)
+       ) {
+               /* then replace the last event with the current event! */
+               qelt->event = *event;
+               return;
+       }
+       if (qelt = _qfree) {
+               /* If _qfree is non-NULL do this, else malloc a new one. */
+               _qfree = qelt->next;
+       }
+       else if ((qelt = (_QEvent *) malloc((unsigned)sizeof(_QEvent))) == NULL) {
+               /* Malloc call failed! */
+               errno = ENOMEM;
+               _XIOError(dpy);
+       }
+       qelt->next = NULL;
+       qelt->event = *event;
+       if (dpy->tail) {
+               dpy->tail->next = qelt;
+       }
+       else {
+               dpy->head = qelt;
+       }
+       dpy->tail = qelt;
+       dpy->qlen++;
+}
+
+
+/*
+ * Undefine the routine pointers so we can define the following default
+ * routines.
+ */
+#undef _XError
+#undef _XIOError
+
+
+/*
+ * _XIOError - Default fatal system error reporting routine.  Called when
+ * an X internal system error is encountered.
+ */
+/*ARGSUSED*/
+_XIOError (dpy)
+       Display *dpy;
+{
+       perror("XIO");
+       exit(1);
+}
+
+
+/*
+ * _XError - Default non-fatal error reporting routine.  Called when an
+ * X_Error packet is encountered in the input stream.
+ */
+_XError (dpy, rep)
+    Display *dpy;
+    XErrorEvent *rep;
+{
+    fprintf(stderr, "X Error: %s\n", XErrDescrip (rep->error_code));
+    fprintf(stderr, "         Request code: %d\n", rep->request_code);
+    fprintf(stderr, "         Request function: %d\n", rep->func);
+    fprintf(stderr, "         Request window 0x%x\n", rep->window);
+    fprintf(stderr, "         Error Serial #%d\n", rep->serial);
+    fprintf(stderr, "         Current serial #%d\n", dpy->request);
+    exit(1);
+}
+
+int (*_XIOErrorFunction)() = _XIOError;
+int (*_XErrorFunction)() = _XError;
+
+#ifdef BIGSHORTS
+UnpackShorts(from, to, bytes)
+       ushort_p *from;
+       short *to;
+       unsigned bytes;
+{
+       unsigned i;
+       for (i = 0; i < (bytes/psizeof(short)); i++)
+               if (i&1)
+                       to[i] = from[i>>1].right;
+               else
+                       to[i] = from[i>>1].left;
+}
+
+char packbuffer[1000];
+PackData(dpy, data, len)
+    register Display *dpy;
+    short *data;
+    unsigned len;
+{
+       if (dpy->bufptr + len < dpy->bufmax) {
+               PackShorts(data, dpy->bufptr, len);
+               dpy->bufptr += (len + 3) & ~3;
+       } else {
+               PackShorts(data, packbuffer, len);
+               _XSend(dpy, packbuffer, len);
+       }
+}
+
+PackShorts(from, to, bytes)
+       short *from;
+       char *to;
+       unsigned bytes;
+{
+       unsigned i, n, offset;
+       ushort_p *uto;
+
+       uto = (ushort_p *)to;
+       offset = ((int)to & 2) >> 1; /* lost 2 bits of pointer */
+       n = (bytes / 2) + offset;
+       for (i = offset; i < n; i++) {
+               if (i&1)
+                       uto[i>>1].right = from[i-offset];
+               else
+                       uto[i>>1].left = from[i-offset];
+       }
+}
+#endif
diff --git a/usr/src/new/X/Xlib/XlibInternal.h b/usr/src/new/X/Xlib/XlibInternal.h
new file mode 100644 (file)
index 0000000..d4be2d7
--- /dev/null
@@ -0,0 +1,88 @@
+#include <X/mit-copyright.h>
+
+/* $Header: XlibInternal.h,v 10.9 86/04/22 15:22:19 jg Rel $ */
+/* Copyright 1984, 1985  Massachusetts Institute of Technology */
+
+/*
+ *     XlibInternal.h - Header definition and support file for the internal
+ *     support routines (XlibInternal) used by the C subroutine interface
+ *     library (Xlib) to the X Window System.
+ *
+ */
+
+#include <sys/types.h>
+#include "Xlib.h"
+#include "../X/Xproto.h"
+#include <stdio.h>
+#include <netinet/in.h>
+#include <sys/ioctl.h>
+#include <netdb.h>
+#include <errno.h>
+
+extern int errno;                      /* Internal system error number. */
+extern char *malloc();                 /* commonly used in the library. */
+extern char *realloc();                        /* used with some frequency.     */
+
+extern Display *_XlibCurrentDisplay;   /* Currently active Display. */
+
+extern (*_XIOErrorFunction)();         /* X system error reporting routine. */
+extern (*_XErrorFunction)();           /* X_Error event reporting routine. */
+
+/*
+ * Boolean datatype.
+ */
+
+typedef enum _bool {FALSE, TRUE} Bool;
+
+/* Pointers to the above routines. */
+#define _XIOError (*_XIOErrorFunction)
+#define _XError (*_XErrorFunction)
+
+#define BUFSIZE 2048                   /* X output buffer size. */
+
+
+/*
+ * X Protocol packetizing macros.
+ */
+
+
+/*
+ * GetReq - Get the next avilable X request packet in the buffer and
+ * return it. 
+ *
+ * "cd" is the X protocol code.
+ * "id" is the window id of the requesting window.
+ */
+#define GetReq(cd, id) \
+       dpy = _XlibCurrentDisplay;\
+       if ((dpy->bufptr + sizeof(XReq)) > dpy->bufmax)\
+               _XFlush(dpy);\
+       req = (XReq *)dpy->bufptr;\
+       req->code = cd;\
+       req->windowId = id;\
+       dpy->bufptr += sizeof(XReq);\
+       dpy->request++;\
+       dpy->lastdraw = NULL
+
+/*
+ * Data - Place data in the buffer and pad the end to provide
+ * 32 bit word alignment.  Transmit if the buffer fills.
+ *
+ * "dpy" is a pointer to a Display.
+ * "data" is a pinter to a data buffer.
+ * "len" is the length of the data buffer.
+ */
+#define Data(dpy, data, len) \
+       if (dpy->bufptr + len < dpy->bufmax) {\
+               bcopy(data, dpy->bufptr, len);\
+               dpy->bufptr += (len + 3) & ~3;\
+       } else\
+               _XSend(dpy, data, len)
+
+#ifndef BIGSHORTS
+#define PackData(dpy, data, len) Data(dpy, (char *) data, len)
+#define PackShorts(f, t, n)  bcopy((char *)f, t, n)
+#endif
+
+
+
diff --git a/usr/src/new/X/Xlib/Xtext.h b/usr/src/new/X/Xlib/Xtext.h
new file mode 100644 (file)
index 0000000..38a59ca
--- /dev/null
@@ -0,0 +1,34 @@
+/* $Header: Xtext.h,v 10.4 86/04/23 12:04:49 jg Rel $ */
+/* Include file for X text window package.  An application using this
+   package modifies any of the fields at its own risk! */
+
+#include <X/Xlib.h>
+
+typedef struct _TextWindow {
+       struct _TextWindow *next; /* for linked list of TextWindows */
+       Window w;               /* Window to use */
+       FontInfo *font;         /* Font to use for text */
+       int fgpixel;            /* Pixel value of foreground */
+       int bgpixel;            /* Pixel value of background */
+       short num_lines;        /* Number of lines in the window */
+       short num_chars;        /* The length of each line */
+       short mapped;           /* Whether or not the window is mapped */
+       short height;           /* Height of window in pixels */
+       short width;            /* Width of window in pixels */
+       short first_line;       /* The index of the first line */
+       char **lines;           /* Ptr to array of text lines */
+       short *line_length;     /* Ptr to array of line lengths (in pixels) */
+       short *line_chars;      /* Ptr to array of line lengths in chars */
+       short last_line;        /* Which line is the last */
+       short last_char;        /* Length of the last line */
+       short next_x;           /* X-coord for next character */
+       short next_y;           /* Y-coord for next character */
+       unsigned int eventmask; /* List of events we're interested in */
+       char *scroll_history;   /* Ptr to list of scroll amounts */
+       short scroll_count;     /* Number of outstanding scrolls */
+       short scroll_start;     /* Where in the history the history starts */
+       short old_scrolls;      /* Number of ignorable outstanting scrolls */
+       short fastscroll;       /* Whether or not to use fast scrolling */
+} TextWindow; 
+
+TextWindow *TextCreate();
diff --git a/usr/src/new/X/Xlib/Xtextlib.c b/usr/src/new/X/Xlib/Xtextlib.c
new file mode 100644 (file)
index 0000000..e58ae2b
--- /dev/null
@@ -0,0 +1,846 @@
+/* $Header: Xtextlib.c,v 10.6 86/04/23 12:03:28 jg Rel $ */
+/* Library of routines for creating a simple text output window.
+ *
+ * Routines in the library are:
+ *
+ *     TextCreate              Creates a new instance of a text window
+ *     TextDestroy             Destroys the window
+ *     TextClear               Clears a text window
+ *     TextRedisplay           Redisplays one or all windows
+ *     TextEvent               Handles exposure and unmapping events
+ *     TextFlush               Flush and handle all outstanding events for
+ *                             one or all TextWindows.
+ *     TextPutString           Displays a string in a text window
+ *     TextPutChar             Displays a character in a text window
+ *     TextPrintf              Does a printf in a text window
+ *
+ * Most of these routines pass around a pointer to a TextWindow data structure:
+ *
+ * typedef struct _TextWindow {
+ *     Window w;               Window to use
+ *     FontInfo *font;         Font to use for text
+ *     short num_lines;        Number of lines in the window
+ *     short num_chars;        The length of each line
+ *     short mapped;           Whether or not the window is mapped
+ *     short height;           Height of window in pixels
+ *     short width;            Width of window in pixels
+ *     short first_line;       The index of the first line
+ *     char **lines;           Ptr to array of text lines
+ *     short *line_length;     Ptr to array of line lengths (in pixels)
+ *     short *line_chars;      Ptr to array of line lengths in chars
+ *     short last_line;        Which line is the last
+ *     short last_char;        Length of the last line
+ *     short next_x;           X-coord for next character
+ *     short next_y;           Y-coord for next character
+ *     unsigned int eventmask; List of events we're interested in
+ *     char *scroll_history;   Ptr to list of scroll amounts
+ *     short scroll_count;     Number of outstanding scrolls
+ *     short scroll_start;     Where in the history the history starts
+ *     short old_scrolls;      Number of ignorable outstanding scrolls
+ *     short fastscroll;       Whether or not to use fast scrolling
+ * } TextWindow; 
+ *
+ * Applications should not modify anything in this data structure, obviously!
+ * They may, however, have reason to get information out of it. (Such as the
+ * window id for mapping).
+ *
+ * Information about the first line of the window is stored in the array
+ * entries subscripted by [first_line]; the arrays wrap back up at the end.
+ * Last_char should always be the same as line_chars[last_line]. 
+ * Similarly, next_x should always be the same as line_length[last_line];
+ *
+ * The only complicated thing about these procedures is the way they keep
+ * track of scrolling.  When a scroll is done, X sends ExposeRegions for
+ * every region that needs to be patched up and then an ExposeCopy event.
+ * The ExposeCopy comes even if there were no regions.  The only problem
+ * is that more scrolls may have been done in the meantime.  So we keep a
+ * history of how much cumulative scrolling has been done in the
+ * scroll_history list.  scroll_start tells which one to start with, and
+ * scroll_count tells how many there are (they wrap around).  The list is
+ * num_lines long since anything that's scrolled away longer ago than that
+ * has scrolled off the screen.  The old_scrolls field gets set whenever the
+ * screen is fully updated for some reason or other; it means that that
+ * many ExposeCopy events can be completely ignored since the screen has
+ * been fully updated.
+ */
+
+#include <stdio.h>
+#include "Xtext.h"
+
+#ifndef TRUE
+#define TRUE 1
+#define FALSE 0
+#endif
+
+/* Define the width of the left margin */
+
+#define mar_width 2
+
+char *calloc(), *malloc(), *realloc();
+
+/* The following variable is sometimes set by TextPutString to temporarily
+   disable screen updating. */
+
+static int dont_update = FALSE;
+\f
+/*
+ * the following variable is the head pointer to a list of TextWindows
+ */
+static TextWindow *head=NULL;
+
+
+/*
+ * add a new TextWindow to the list of TextWindows created for this
+ * process.
+ */
+static AddTextWindow(t)
+       TextWindow *t;
+{      
+       TextWindow *p;
+
+       t->next = NULL;
+       if (head) {
+               p = head;
+               while (p->next) p = p->next;
+               p->next = t;
+       } else {
+               head = t;
+       }
+}
+
+
+/*
+ * delete a TextWindow from the list of TextWindows created for this
+ * process.
+ */
+static DelTextWindow(t)
+       TextWindow *t;
+{
+       TextWindow *p=head;
+
+       if (!p) return;         /* shouldn't happen! no list. */
+       if (p==t) {
+               head = t->next;
+       } else {
+               while (p->next && (t != p->next)) p = p->next;
+               if (t != p->next) return;  /* shouldn't happen! not found */
+               p->next = t->next;
+       }
+}
+\f
+/* TextCreate creates a new window which will use the
+ * specified font.  The window is height lines high and width
+ * characters wide.  Note that since a variable-width font may be
+ * used, the width is calculated using the average width of the font.
+ * Colors are used as specified.
+ */
+
+TextWindow *TextCreate (width, height, x, y, parent, fontname,
+               bwidth, fgpixel, bgpixel, bordercolor, fastscroll)
+       int height, width, x, y, bwidth, fastscroll;
+       Window parent;
+       char *fontname;
+       int fgpixel, bgpixel;
+       Pixmap bordercolor;
+{
+       register TextWindow *t;
+       register int i;
+       register FontInfo *f;
+       Window XCreateWindow();
+       Pixmap bgpixmap;
+
+       if ((t = (TextWindow *) malloc(sizeof(TextWindow))) ==
+               NULL) return NULL;
+
+       AddTextWindow(t);               /* add to list of TextWindows */
+
+       if ((f = t->font = XOpenFont(fontname)) == NULL) {
+           TextDestroy(t);
+           return NULL;
+       }
+
+       t->fgpixel = fgpixel;
+       t->bgpixel = bgpixel;
+
+       if ((bgpixmap = XMakeTile(bgpixel)) == NULL) {
+           TextDestroy(t);
+           return NULL;
+       }
+
+       t->width = width * f->width + mar_width;
+       t->height = height * f->height;
+
+       t->w = XCreateWindow (parent, x, y, t->width, t->height,
+               bwidth, bordercolor, bgpixmap);
+       if (t->w == NULL) {
+           TextDestroy(t);
+           XFreePixmap(bgpixmap);
+           return NULL;
+       }
+
+       XFreePixmap(bgpixmap);
+
+       t->eventmask = ExposeRegion | ExposeWindow | ExposeCopy | UnmapWindow;
+       /* (ExposeRegion automatically selects ExposeWindow) */
+
+       XSelectInput (t->w, t->eventmask);
+
+       XSetResizeHint (t->w, mar_width, 0, f->width, f->height);
+       t->fastscroll = fastscroll;
+       t->mapped = FALSE;
+       t->num_lines = height;
+       t->num_chars = width;
+
+       t->first_line = 0;
+
+       if ((t->lines = (char **)
+               calloc (height, sizeof (char *))) == NULL) {
+           TextDestroy(t);
+           return NULL;
+       }
+
+       if ((t->line_length = (short *)
+               calloc (height, sizeof (short))) == NULL) {
+           TextDestroy(t);
+           return NULL;
+       }
+
+       if ((t->line_chars = (short *)
+               calloc (height, sizeof (short))) == NULL) {
+           TextDestroy(t);
+           return NULL;
+       }
+
+       for (i = 0; i < height; i++) {
+           if ((t->lines[i] = (char *)
+                   calloc (width+1, sizeof (char))) == NULL) {
+               TextDestroy(t);
+               return NULL;
+           }
+       }
+
+       if ((t->scroll_history = calloc(height, sizeof (char))) == NULL) {
+           TextDestroy(t);
+           return NULL;
+       }
+
+       t->scroll_count = t->scroll_start = t->old_scrolls = 0;
+       TextClear(t);
+       return t;
+}
+\f
+/* Free all the storage associated with a textwindow */
+
+TextDestroy(t)
+       register TextWindow *t;
+{
+       register int i;
+
+       /* Free things in the order we allocated them.  If something doesn't
+          exist, don't free it!) */
+
+       if (t->font) {
+           if (t->font->fixedwidth == 0) free((char *)t->font->widths);
+           free((char *)t->font);
+       }
+
+       if (t->w) XDestroyWindow(t->w);
+
+       if (t->lines) {
+           for (i = 0; i < t->num_lines; i++) {
+               if (t->lines[i]) free((char *)t->lines[i]);
+           }
+           free((char *)t->lines);
+       }
+
+       if (t->line_length) free ((char *)t->line_length);
+       if (t->line_chars) free ((char *)t->line_chars);
+       if (t->scroll_history) free (t->scroll_history);
+
+
+       DelTextWindow(t);       /* remove from list of TextWindows */
+
+       /* And finally the data structure itself! */
+       free ((char *)t);
+}
+\f
+/* Clear out a text window and redisplay */
+
+TextClear(t)
+       register TextWindow *t;
+{
+       register int i;
+
+       for (i = 0; i < t->num_lines; i++) {
+           t->lines[i][0] = '\0';
+           t->line_chars[i] = 0;
+           t->line_length[i] = mar_width;      /* Allow a left margin */
+       }
+       t->last_line = 0;
+       t->last_char = 0;
+       t->next_x = mar_width;          /* Allow a left margin */
+       t->next_y = 0;
+       t->first_line = 0;
+
+       TextRedisplay(t);
+}
+\f
+/* Redisplays a text window */
+
+TextRedisplay (t)
+       register TextWindow *t;
+{
+       if (t==NULL) {
+               for (t = head; t!=NULL; t = t->next) {
+                       TextRedisplay(t);
+               }
+               return;
+       }
+       if (!t->mapped) return;
+
+       /* Clear the border area */
+
+       XPixSet(t->w, 0, 0, mar_width, t->height, t->bgpixel);
+
+       Redisplay_lines(t, 0, t->num_lines - 1);
+
+       /* Any outstanding copies from scrolls can now be ignored */
+
+       t->old_scrolls = t->scroll_count;
+       t->scroll_count = t->scroll_start = 0;
+}
+
+Redisplay_lines(t, start, finish)
+       register TextWindow *t;
+       int start, finish;
+{
+       register int i, j, y, height = t->font->height, x, width;
+
+       if (finish < 0) return;
+       if (start < 0) start = 0;
+
+       y = start * height;
+       j = start + t->first_line;
+
+       for (i = start; i <= finish; i++) {
+           if (j >= t->num_lines) j = 0;
+
+           if (t->line_chars[j]) {
+               XText (t->w, mar_width, y, t->lines[j], t->line_chars[j],
+                       t->font->id, t->fgpixel, t->bgpixel);
+           }
+
+           x = t->line_length[j];
+           width = t->width - x;
+
+           if (width > 0) XPixSet(t->w, x, y, width, height, t->bgpixel);
+           y += height;
+           j++;
+       }
+}
+\f
+/* Handles an event.  If it's not an event it knows how to deal with,
+   returns TRUE, otherwise FALSE. */
+
+int TextEvent(t, e)
+       register TextWindow *t;
+       XEvent *e;
+{
+       XExposeEvent *ee = (XExposeEvent *) e;
+       int offset;
+
+       switch (e->type) {
+           case ExposeWindow:
+               if (ee->height != t->height || ee->width != t->width) {
+                   Change_text_window_size(t, ee->height / t->font->height,
+                           ee->width / t->font->width);
+               }
+               t->mapped = TRUE;
+               TextRedisplay(t);
+               break;
+
+           case ExposeRegion:
+               /* If there have been more scrolls than there are lines,
+                  this stuff has already scrolled off! */
+
+               if (t->scroll_count > t->num_lines) return FALSE;
+
+               /* If this is for an old scroll, ignore it */
+
+               if (ee->detail == ExposeCopy && t->old_scrolls) return FALSE;
+
+               if (t->scroll_count > 0) {
+                   offset = t->scroll_history[t->scroll_start];
+               } else offset = 0;
+               Redisplay_lines(t, ee->y / t->font->height - offset,
+                       (ee->y + ee->height - 1) / t->font->height - offset);
+               break;
+
+           case UnmapWindow:
+               t->mapped = FALSE;
+               break;
+
+           case ExposeCopy:    /* We've finished the events for one scroll */
+               /* If there are old scrolls, just decrement the count and
+                  return */
+
+               if (t->old_scrolls) {
+                   t->old_scrolls--;
+                   return FALSE;
+               }
+               t->scroll_count--;
+               if (t->scroll_count < t->num_lines) {
+                   t->scroll_start++;
+                   if (t->scroll_start >= t->num_lines) t->scroll_start = 0;
+               }
+               break;
+
+           default:
+               return TRUE;
+       }
+       return FALSE;
+}
+\f
+/*
+ * Flush all outstanding events for all existent TextWindows.
+ */
+TextFlush(t)
+       TextWindow *t;
+{
+       XEvent e;
+
+       if (t==NULL) {
+               for (t=head; t!=NULL; t=t->next) {
+                       TextFlush(t);
+               }
+               return;
+       }
+
+       XSync(0);
+
+       while (XCheckWindowEvent(t->w,t->eventmask|ExposeWindow,&e)) {
+               if (TextEvent(t,&e)) {
+                       /* 
+                        * We should never get here. Accordingly, we
+                        * don't do anything if we do, somehow, get here.  
+                        */
+               }
+       }
+
+}
+\f
+Change_text_window_size (t, new_h, new_w)
+       register TextWindow *t;
+       register int new_h, new_w;
+{
+       register int i;
+       register char *curline;
+
+       Normalize(t);           /* Rearrange lines so that first_line = 0 */
+
+       /* First free up any now extraneous lines */
+
+       for (i = new_h; i < t->num_lines; i++) free((char *)t->lines[i]);
+
+       if ((t->lines = (char **)
+               realloc((char *)t->lines, new_h * sizeof (char *))) == NULL) {
+           return;
+       }
+
+       if ((t->line_length = (short *)
+               realloc((char *)t->line_length, new_h * sizeof (short))) == NULL) {
+           return;
+       }
+
+       if ((t->line_chars = (short *)
+               realloc((char *)t->line_chars, new_h * sizeof (short))) == NULL) {
+           return;
+       }
+
+       if ((t->scroll_history = realloc(t->scroll_history, new_h)) == NULL) {
+           return;
+       }
+
+       for (i = 0; i < new_h; i++) {
+           if (i < t->num_lines) {
+               if ((curline = t->lines[i] =
+                       realloc(t->lines[i], new_w + 1)) == NULL) {
+                   return;
+               }
+
+               if (t->line_chars[i] > new_w) {
+                   t->line_chars[i] = new_w;
+                   curline[new_w] = '\0';      /* Truncate the line */
+                   t->line_length[i] = mar_width +
+                           XStringWidth (curline, t->font, 0, 0);
+               }
+           } else {
+               if ((t->lines[i] = malloc(new_w+1)) == NULL) {
+                   return;
+               }
+               t->lines[i][0] = '\0';
+               t->line_chars[i] = 0;
+               t->line_length[i] = mar_width;
+           }
+       }
+
+       if (t->last_line >= new_h) {
+           t->last_line = new_h - 1;
+           t->last_char = t->line_chars[t->last_line];
+           t->next_x = t->line_length[t->last_line];
+           t->next_y = t->last_line * t->font->height;
+
+       } else if (t->last_char > new_w) {
+           t->last_char = t->line_chars[t->last_line];
+           t->next_x = t->line_length[t->last_line];
+       }
+
+       t->num_lines = new_h;
+       t->num_chars = new_w;
+       t->height = new_h * t->font->height;
+       t->width = new_w * t->font->width + mar_width;
+}
+\f
+/* Routine to re-arrange the lines in a window structure so that first_line
+   is equal to 0. */
+
+Normalize(t)
+       register TextWindow *t;
+{
+       if (t->first_line == 0) return;
+
+       t->last_line -= t->first_line;
+       if (t->last_line < 0) t->last_line += t->num_lines;
+
+       Spin_lines(t, 0, t->num_lines-1, t->first_line);
+
+       t->first_line = 0;
+}
+
+/* Spin lines rotates the m through n lines of the arrays
+   forward offset places.  For example, 012345 spun forward 2 is 234501.
+   It's straightforward to spin the first part of the arrays; and we
+   call Spin_lines recursively to do the last offset elements */
+
+/* Actually, it's tail-recursive, so I just use a loop.  But I can
+   pretend, can't I? */
+
+Spin_lines(t, m, n, offset)
+       register TextWindow *t;
+       int m, n;
+       register int offset;
+{
+       register int i;
+       register int temp;              /* Temporaries */
+       register char *tempc;
+
+       while (1) {
+           if (offset == 0 || offset > n-m) return;
+
+           for (i = m; i <= n-offset; i++) {
+               temp = t->line_length[i];
+               t->line_length[i] = t->line_length[offset+i];
+               t->line_length[offset+i] = temp;
+
+               temp = t->line_chars[i];
+               t->line_chars[i] = t->line_chars[offset+i];
+               t->line_chars[offset+i] = temp;
+
+               tempc = t->lines[i];
+               t->lines[i] = t->lines[offset+i];
+               t->lines[offset+i] = tempc;
+           }
+
+/*         Spin_lines(t, n-offset+1, n, offset - ((n-m+1) % offset)); */
+
+           temp = m;
+           m = n - offset + 1;
+           offset -= (n - temp + 1) % offset;
+       }
+}
+\f
+/* Routine to put a string in a text window.  If fastscroll is
+   set in the TextWindow structure, a single block scroll is done instead
+   of scrolling at each newline. */
+
+#define verybig 10000  /* Amount to scroll if we should refresh instead */
+
+TextPutString (t, str)
+       register TextWindow *t;
+       register char *str;
+{
+       register char *ch = str;
+       register char oldch;
+       int jump = t->fastscroll;       /* Whether to do jump scrolling */
+       int newlines, scroll;
+
+       if (jump) jump = Count_lines (t, str, &newlines, &scroll);
+
+       while (1) {
+           while (*ch != '\0' && *ch != '\n') ch++;
+           if (ch != str) {
+               oldch = *ch;
+               *ch = '\0';
+               Do_text_string (t, str);
+               *ch = oldch;
+           }
+           if (*ch == '\0') break;
+           if (jump && newlines == scroll) {
+               Clear_lines (t, newlines);
+               dont_update = TRUE;     /* Stop updating now */
+           }
+           newlines--;
+           TextPutChar (t, *ch);
+           str = ++ch;
+       }
+       if (t->mapped && jump) {
+           if (scroll != verybig) Scroll_text_window (t, scroll);
+           else TextRedisplay (t);
+       }
+       dont_update = FALSE;
+}
+\f
+/* Count the number of lines in str, calculate how much scrolling
+   will be needed, and return whether this amount is positive */
+
+int Count_lines (t, str, newlines, scroll)
+       register TextWindow *t;
+       register char *str;
+       int *newlines, *scroll;
+{
+       register int num_lines = 0;
+       register int lines_left, height = t->num_lines;
+
+       *scroll = 0;
+
+       while (*str) {
+           if (*str++ == '\n') num_lines++;
+       }
+
+       *newlines = num_lines;
+
+       if (num_lines <= 1) return FALSE;    /* Don't bother jump scrolling */
+
+       /* Would this fill the screen? */
+
+       if (num_lines >= height) {
+           *scroll = verybig;
+           return TRUE;
+       }
+
+       /* Calculate the number of lines left in the window */
+
+       lines_left = height - (t->last_line - t->first_line + 1);
+       if (lines_left >= height) lines_left -= height;
+
+       /* Figure out how many lines to scroll */
+
+       num_lines -= lines_left;
+
+       if (num_lines <= 0) return FALSE;       /* Enough room already */
+
+       *scroll = num_lines;
+       return TRUE;
+}
+\f
+/* Clear a number of lines in the window data structure */
+
+Clear_lines (t, scroll)
+       register TextWindow *t;
+       register int scroll;
+{
+       register int i, start = t->first_line;
+       register int height = t->num_lines;
+
+       /* If this would fill the screen, clear it instead */
+
+       if (scroll >= t->height ) {
+           TextClear (t);
+           return;
+       }
+
+       /* Shift the contents */
+
+       t->first_line += scroll;
+       if (t->first_line >= height) t->first_line -= height;
+
+       /* Now clear the blank lines */
+
+       for (i = 0; i < scroll; i++) {
+           t->lines[start][0] = '\0';
+           t->line_chars[start] = 0;
+           t->line_length[start] = mar_width;  /* Allow a left margin */
+           start++;
+           if (start >= height) start = 0;
+       }
+}
+\f
+/* Store the characters of a string in the window and update the screen,
+   but only if dont_update isn't set */
+
+Do_text_string (t, str)
+       register TextWindow *t;
+       char *str;
+{
+       register char *ch = str;
+       register char *curline = t->lines[t->last_line];
+       register int curchar = t->last_char;
+       register int x = t->next_x;
+       register FontInfo *f = t->font;
+       int start_x = t->next_x, start = curchar,
+               minch = f->firstchar, maxch = f->lastchar;
+
+       /* First store the characters in the line */
+
+       while (*ch != '\0' && curchar < t->num_chars) {
+           curline[curchar] = *ch;
+           if (*ch >= minch && *ch <= maxch) {
+               x += f->fixedwidth ? f->width : f->widths[*ch - minch];
+           }
+           curchar++;
+           ch++;
+       }
+
+       curline[curchar] = '\0';
+       t->line_chars[t->last_line] = t->last_char = curchar;
+       t->line_length[t->last_line] = t->next_x = x;
+
+       if (dont_update || !t->mapped) return;
+
+       /* And then update the screen */
+
+       if (start < t->num_chars) {
+           XText (t->w, start_x, t->next_y, str, curchar-start,
+                   f->id, t->fgpixel, t->bgpixel);
+       }
+}
+\f
+/* Textputchar displays a character in the text window.  It
+ * responds to \n as a special character and just displays anything else.
+ */
+
+TextPutChar (t, ch)
+       register TextWindow *t;
+       char ch;
+{
+       register int i, height = t->num_lines;
+       register char *curline = t->lines[t->last_line];
+       register FontInfo *f = t->font;
+       
+       switch (ch) {
+           case '\0':          /* NULL */
+               break;
+
+           case '\n':          /* newline */
+               if (t->last_line == t->first_line - 1 ||
+                       (t->last_line == height - 1 && t->first_line == 0)) {
+
+                   /* The screen is full...clear out the first line */
+
+                   t->lines[t->first_line][0] = '\0';
+                   t->line_chars[t->first_line] = 0;
+                   t->line_length[t->first_line] = mar_width;
+
+                   t->first_line++;                    /* And advance it */
+                   if (t->first_line == height) t->first_line = 0;
+
+                   if (!dont_update && t->mapped) Scroll_text_window (t, 1);
+
+               } else if (!dont_update) t->next_y += f->height;
+
+               t->last_line++;
+               if (t->last_line == height) t->last_line = 0;
+
+               t->last_char = 0;
+               t->next_x = mar_width;
+               break;
+
+           default:            /* Just insert the character */
+               t->last_char++;
+               t->line_chars[t->last_line]++;
+               if (t->last_char > t->num_chars) break;
+
+               curline[t->last_char] = ch;
+               curline[t->last_char+1] = '\0';
+
+               if (!dont_update && t->mapped) {
+                   XText(t->w, t->next_x, t->next_y, &ch, 1,
+                           f->id, t->fgpixel, t->bgpixel);
+               }
+               if (ch <= f->firstchar && ch >= f->lastchar) {
+                   t->line_length[t->last_line] = t->next_x +=
+                           (f->fixedwidth ? f->width :
+                                            f->widths[ch - f->lastchar]);
+               }
+               break;
+       }
+}
+\f
+/* This procedure moves the contents of a text window up n lines.
+ */
+
+Scroll_text_window (t, n)
+       register TextWindow *t;
+       register int n;
+{
+       register int i, y, x, width, j;
+       int height = t->font->height;
+       int scrollsize = n * height;
+
+       /* First shift up the contents */
+
+       XMoveArea(t->w, 0, scrollsize, 0, 0, t->width, t->height-scrollsize);
+
+       /* Now redisplay the bottom n lines */
+
+       y = height * (t->num_lines - n);
+       i = t->first_line - n;
+       if (i < 0) i += t->num_lines;
+
+       for (j = 0; j < n; j++) {
+           if (t->line_chars[i]) {
+               XText (t->w, mar_width, y, t->lines[i], t->line_chars[i],
+                       t->font->id, t->fgpixel, t->bgpixel);
+           }
+           x = t->line_length[i];
+           width = t->width - x;
+
+           if (width > 0) XPixSet(t->w, x, y, width, height, t->bgpixel);
+           y += height;
+           i++;
+           if (i == t->num_lines) i = 0;
+       }
+
+       /* Add the current scroll to all values in the scroll history,
+          then add a new entry at the end (the history wraps!) */
+
+       i = t->scroll_start;
+
+       for (j = 0; j < t->scroll_count; j++) {
+           t->scroll_history[i] += n;
+           i++;
+           if (i >= t->num_lines) i = 0;
+       }
+       t->scroll_count++;
+       t->scroll_history[i] = n;
+
+       if (t->scroll_count > t->num_lines) t->scroll_start++; /* trash one */
+}
+\f
+#define TEXT_BUFSIZE 2048
+
+TextPrintf(t, format, args)
+       TextWindow *t;
+       char *format;
+{
+       char buffer[TEXT_BUFSIZE+1];
+       struct _iobuf _strbuf;
+
+       _strbuf._flag = _IOWRT+_IOSTRG;
+       _strbuf._ptr = buffer;
+       _strbuf._cnt = TEXT_BUFSIZE;
+       _doprnt(format, &args, &_strbuf);
+       _strbuf._cnt++;     /* Be sure there's room for the \0 */
+       putc('\0', &_strbuf);
+       TextPutString(t, buffer);
+}
diff --git a/usr/src/new/X/Xlib/Xtty.h b/usr/src/new/X/Xlib/Xtty.h
new file mode 100644 (file)
index 0000000..c30729b
--- /dev/null
@@ -0,0 +1,9 @@
+/* $Header: Xtty.h,v 10.3 86/02/01 15:42:44 tony Rel $ */
+typedef struct _TTYWindow {
+       Window w;               /* The window id */
+       int pid;                /* The pid of the subprocess xterm */
+       short file;             /* The file id of the tty to read and write 
+                                  characters to/from */
+} TTYWindow;
+
+TTYWindow *CreateTTYWindow();
diff --git a/usr/src/new/X/Xlib/Xttylib.c b/usr/src/new/X/Xlib/Xttylib.c
new file mode 100644 (file)
index 0000000..a6cb6f6
--- /dev/null
@@ -0,0 +1,237 @@
+#ifndef lint
+static char *rcsid_Xttylib_c = "$Header: Xttylib.c,v 10.7 86/04/22 15:18:10 jg Rel $";
+#endif
+/* This version has a single reverse-video argument instead of colors.  It
+   really only works well on monochrome displays */
+
+/* Library of routines to create a terminal emulator window
+ *
+ * Routines in this library are:
+ *
+ *     CreateTTYWindow         Creates a new instance of a terminal window
+ *     DestroyTTYWindow        Destroys a terminal window
+ *     TTYPutString            Puts a string in a terminal window
+ *     TTYPutChar              Puts a character in a terminal window
+ *     TTYPrintf               Does a printf in a terminal window
+ *     TTYGetString            Gets s string from a terminal window
+ *     TTYGetChar              Gets a char from a terminal window
+ *     SetStdout               Flushes stdout and assigns it to a window
+ *     ResetStdout             Resets stdout to its inital value
+ *
+ * The terminal window created responds to exactly the same character
+ * sequences as xterm (not surprising).  Creating a window automatically
+ * maps it
+ *
+ * These routines pass around a pointer to a TTYWindow:
+ *
+ * typedef struct _TTYWindow {
+ *     Window w;               The window id
+ *     int pid;                The pid of the subprocess xterm
+ *     short file;             The file id of the tty to read/write characters to/from
+ * } TTYWindow;
+ *
+ *
+ * The SetStdout routine is highly useful in conjunction with curses
+ * since curses always writes to stdout.
+ */
+
+#include <X/Xlib.h>
+#include <stdio.h>
+#include <signal.h>
+#include <sys/file.h>
+#include <sys/ioctl.h>
+#include <sgtty.h>
+#include "Xtty.h"
+
+TTYWindow *CreateTTYWindow(cols, lines, x, y, normFont, boldFont, bwidth,
+               reverse)
+       int lines, cols, x, y, bwidth, reverse;
+       char *normFont, *boldFont;
+{
+       TTYWindow *t;
+
+       if ((t = (TTYWindow *) malloc(sizeof(TTYWindow))) ==
+               NULL) return NULL;
+
+       if (Start_slave_xterm(t, lines, cols, x, y, normFont, boldFont,
+               bwidth, reverse) == 0) {
+           free((char *)t);
+           fprintf(stderr, "Couldn't start slave xterm\n");
+           return NULL;
+       }
+
+       return t;
+}
+
+int ttyMasterPty;
+int keepMasterOpen = 0;
+
+int Start_slave_xterm(t, lines, cols, x, y, normFont, boldFont, bwidth,
+               reverse)
+       TTYWindow *t;
+       int lines, cols, x, y, bwidth, reverse;
+       char *normFont, *boldFont;
+{
+#define BUFSIZE 20
+
+       char ttyName[BUFSIZE];
+       char Sbuf[BUFSIZE], sizeBuf[BUFSIZE], wdBuf[BUFSIZE],
+               inputBuffer[BUFSIZE];
+       int bytesRead, len;
+
+       if (boldFont == NULL) boldFont = normFont;
+
+       ttyMasterPty = GetPty(ttyName);
+       if (ttyMasterPty == -1) return 0;
+
+       if ((t->pid = vfork()) < 0) return 0;
+
+       if (t->pid == 0) {
+           sprintf(Sbuf, "-S%c%c%d", ttyName[8], ttyName[9], ttyMasterPty);
+           sprintf(sizeBuf, "=%dx%d+%d+%d", cols, lines, x, y);
+           sprintf(wdBuf, "%d", bwidth);
+
+           execlp("xterm", "xterm", Sbuf, "-fn", normFont, "-fb", boldFont,
+                   sizeBuf, "-bw", wdBuf, reverse ? "-rv" : (char *) 0,
+                   (char *) 0);
+
+       } else {
+           if (!keepMasterOpen) close(ttyMasterPty);
+
+           /* Open the slave end of the pty */
+
+           ttyName[5] = 't';   /* Change /dev/pty?? to /dev/tty?? */
+
+           t->file = open(ttyName, O_RDWR, 0777);
+           
+           if (t->file < 0) {
+               /* Couldn't open the tty--better get rid of the process */
+               kill (t->pid, SIGINT);
+               return 0;
+           }
+
+           /* Read the windowid from the pty */
+
+           len = 0;
+           while ((bytesRead = read(t->file, inputBuffer + len,
+                   sizeof(Window) - len)) > 0) len += bytesRead;
+
+           /* Flush the rest of the garbahge */
+
+           ioctl(t->file, TIOCFLUSH, (struct sgttyb *) NULL);
+
+           /* the data consists of a binary window ID */
+
+           t->w = *(Window *) inputBuffer;
+       }
+       return 1;
+#undef BUFSIZE
+}
+
+int GetPty(name)
+       char *name;
+{
+       register int devindex, letter;
+       int fd;
+
+       strcpy(name, "/dev/ptyp0");
+
+       for (letter = 0; letter < 4; letter++) {
+           name[8] = "pqrs"[letter];
+           
+           for (devindex = 0; devindex < 16; devindex++) {
+               name[9] = "0123456789abcdef"[devindex];
+               if ((fd = open (name, O_RDWR)) >= 0) return fd;
+           }
+       }
+       
+       return -1;
+}      
+
+DestroyTTYWindow(t)
+       TTYWindow *t;
+{
+       /* close the tty; this should cause the xterm to terminate with an I/O error */
+       close(t->file);  
+       free((char *)t);
+}
+
+TTYPutString(t, str)
+       TTYWindow *t;
+       char *str;
+{
+       write(t->file, str, strlen(str));
+}
+
+TTYPutChar(t, ch)
+       TTYWindow *t;
+       char ch;
+{
+       write(t->file, &ch, 1);
+}
+
+TTYPrintf(t, format, args)
+       TTYWindow *t;
+       char *format;
+{
+#define TTY_BUFSIZE 2048
+       char buffer[TTY_BUFSIZE+1];
+       struct _iobuf _strbuf;
+
+       _strbuf._flag = _IOWRT+_IOSTRG;
+       _strbuf._ptr = buffer;
+       _strbuf._cnt = TTY_BUFSIZE;
+       _doprnt(format, &args, &_strbuf);
+       _strbuf._cnt++;     /* Be sure there's room for the \0 */
+       putc('\0', &_strbuf);
+       TTYPutString(t, buffer);
+#undef TTY_BUFSIZE
+}
+
+static initial_stdout = -1;
+
+SetStdout(t)
+       TTYWindow *t;
+{
+       if (initial_stdout == -1) initial_stdout = stdout->_file;
+       fflush(stdout);
+       stdout->_file = t->file;
+}
+
+ResetStdout()
+{
+       fflush(stdout);
+       stdout->_file = initial_stdout;
+       initial_stdout = -1;
+}
+
+#define CMASK 0377
+
+int TTYGetChar(t)
+       TTYWindow *t;
+{
+       char c;
+
+       if (read(t->file, &c, 1) > 0)
+           return (c & CMASK);
+       else return (EOF);
+}
+
+char *TTYGetString(t, str, n)
+       register TTYWindow *t;
+       char *str;
+       register int n;
+{
+       register char *cs;
+
+       cs = str;
+       while (--n > 0 && read(t->file, cs, 1) > 0) {
+           if (*cs++ == '\n') break;
+       }
+
+       if (cs == str) return NULL;
+
+       *cs = '\0';
+       return str;
+
+}
diff --git a/usr/src/new/X/Xlib/keymap.c b/usr/src/new/X/Xlib/keymap.c
new file mode 100644 (file)
index 0000000..290494a
--- /dev/null
@@ -0,0 +1,263 @@
+#include <X/mit-copyright.h>
+
+/* $Header: keymap.c,v 10.5 86/02/01 15:42:53 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1984, 1985    */
+
+#include "Xlib.h"
+
+KeyMapEntry StdMap [] =
+{
+/* key code    plain   shifted meta    M-shift control C-shift C-M     C-M-S   key label */
+/* 0000 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /* red */
+/* 0001 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /* yellow */
+/* 0002 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /* blue */
+/* 0003 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0004 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0005 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0006 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0007 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0010 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0011 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0012 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0013 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0014 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0015 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0016 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0017 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0020 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0021 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0022 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0023 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0024 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0025 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0026 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0027 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0030 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0031 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0032 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0033 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0034 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0035 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0036 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0037 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0040 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0041 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0042 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0043 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0044 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0045 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0046 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0047 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0050 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0051 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0052 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0053 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0054 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0055 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0056 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0057 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0060 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0061 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0062 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0063 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0064 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0065 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0066 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0067 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0070 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0071 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0072 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0073 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0074 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0075 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0076 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0077 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0100 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0101 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0102 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0103 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0104 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0105 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0106 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0107 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0110 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0111 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0112 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0113 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0114 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0115 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0116 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0117 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0120 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0121 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0122 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0123 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0124 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0125 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0126 */     FUNC1,  FUNC1,  FUNC1,  FUNC1,  FUNC1,  FUNC1,  FUNC1,  FUNC1,  /* F1/Hold Screen */
+/* 0127 */     FUNC2,  FUNC2,  FUNC2,  FUNC2,  FUNC2,  FUNC2,  FUNC2,  FUNC2,  /* F2/Print Screen */
+/* 0130 */     FUNC3,  FUNC3,  FUNC3,  FUNC3,  FUNC3,  FUNC3,  FUNC3,  FUNC3,  /* F3/Set-Up */
+/* 0131 */     FUNC4,  FUNC4,  FUNC4,  FUNC4,  FUNC4,  FUNC4,  FUNC4,  FUNC4,  /* F4 */
+/* 0132 */     FUNC5,  FUNC5,  FUNC5,  FUNC5,  FUNC5,  FUNC5,  FUNC5,  FUNC5,  /* F5/Break */
+/* 0133 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0134 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0135 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0136 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0137 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0140 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0141 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0142 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0143 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0144 */     FUNC6,  FUNC6,  FUNC6,  FUNC6,  FUNC6,  FUNC6,  FUNC6,  FUNC6,  /* F6 */
+/* 0145 */     FUNC7,  FUNC7,  FUNC7,  FUNC7,  FUNC7,  FUNC7,  FUNC7,  FUNC7,  /* F7 */
+/* 0146 */     FUNC8,  FUNC8,  FUNC8,  FUNC8,  FUNC8,  FUNC8,  FUNC8,  FUNC8,  /* F8 */
+/* 0147 */     FUNC9,  FUNC9,  FUNC9,  FUNC9,  FUNC9,  FUNC9,  FUNC9,  FUNC9,  /* F9 */
+/* 0150 */     FUNC10, FUNC10, FUNC10, FUNC10, FUNC10, FUNC10, FUNC10, FUNC10, /* F10 */
+/* 0151 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0152 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0153 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0154 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0155 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0156 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0157 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0160 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0161 */     0033,   0033,   0033,   0033,   0033,   0033,   0033,   0033,   /* F11/ESC */
+/* 0162 */     '\b',   '\b',   '\b',   -1,     '\b',   -1,     -1,     -1,     /* F12/BS */
+/* 0163 */     '\n',   '\n',   '\n',   -1,     '\n',   -1,     -1,     -1,     /* F13/LF */
+/* 0164 */     FUNC14, FUNC14, FUNC14, FUNC14, FUNC14, FUNC14, FUNC14, FUNC14, /* F14 */
+/* 0165 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0166 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0167 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0170 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0171 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0172 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0173 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0174 */     FUNC15, FUNC15, FUNC15, FUNC15, FUNC15, FUNC15, FUNC15, FUNC15, /* Help/F15 */
+/* 0175 */     FUNC16, FUNC16, FUNC16, FUNC16, FUNC16, FUNC16, FUNC16, FUNC16, /* Do/F16 */
+/* 0176 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0177 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0200 */     FUNC17, FUNC17, FUNC17, FUNC17, FUNC17, FUNC17, FUNC17, FUNC17, /* F17 */
+/* 0201 */     FUNC18, FUNC18, FUNC18, FUNC18, FUNC18, FUNC18, FUNC18, FUNC18, /* F18 */
+/* 0202 */     FUNC19, FUNC19, FUNC19, FUNC19, FUNC19, FUNC19, FUNC19, FUNC19, /* F19 */
+/* 0203 */     FUNC20, FUNC20, FUNC20, FUNC20, FUNC20, FUNC20, FUNC20, FUNC20, /* F20/Hyph */
+/* 0204 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0205 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0206 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0207 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0210 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0211 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0212 */     E1,     E1,     E1,     E1,     E1,     E1,     E1,     E1,     /* Find */
+/* 0213 */     E2,     E2,     E2,     E2,     E2,     E2,     E2,     E2,     /* Insert */
+/* 0214 */     E3,     E3,     E3,     E3,     E3,     E3,     E3,     E3,     /* Remove */
+/* 0215 */     E4,     E4,     E4,     E4,     E4,     E4,     E4,     E4,     /* Select */
+/* 0216 */     E5,     E5,     E5,     E5,     E5,     E5,     E5,     E5,     /* Prev Screen */
+/* 0217 */     E6,     E6,     E6,     E6,     E6,     E6,     E6,     E6,     /* Next Screen */
+/* 0220 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0221 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0222 */     KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, /* R0 */
+/* 0223 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0224 */     KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, /* R. */
+/* 0225 */     KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, /* Enter */
+/* 0226 */     KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, /* R1 */
+/* 0227 */     KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, /* R2 */
+/* 0230 */     KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, /* R3 */
+/* 0231 */     KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, /* R4 */
+/* 0232 */     KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, /* R5 */
+/* 0233 */     KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, /* R6 */
+/* 0234 */     KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, /* R, */
+/* 0235 */     KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, /* R7 */
+/* 0236 */     KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, /* R8 */
+/* 0237 */     KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, /* R9 */
+/* 0240 */     KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, KEYPAD, /* R- */
+/* 0241 */     PFX,    PFX,    PFX,    PFX,    PFX,    PFX,    PFX,    PFX,    /* PF1 */
+/* 0242 */     PFX,    PFX,    PFX,    PFX,    PFX,    PFX,    PFX,    PFX,    /* PF2 */
+/* 0243 */     PFX,    PFX,    PFX,    PFX,    PFX,    PFX,    PFX,    PFX,    /* PF3 */
+/* 0244 */     PFX,    PFX,    PFX,    PFX,    PFX,    PFX,    PFX,    PFX,    /* PF4 */
+/* 0245 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0246 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0247 */     CURSOR, CURSOR, CURSOR, CURSOR, CURSOR, CURSOR, CURSOR, CURSOR, /* leftarrow */
+/* 0250 */     CURSOR, CURSOR, CURSOR, CURSOR, CURSOR, CURSOR, CURSOR, CURSOR, /* rightarrow */
+/* 0251 */     CURSOR, CURSOR, CURSOR, CURSOR, CURSOR, CURSOR, CURSOR, CURSOR, /* downarrow */
+/* 0252 */     CURSOR, CURSOR, CURSOR, CURSOR, CURSOR, CURSOR, CURSOR, CURSOR, /* uparrow */
+/* 0253 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0254 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0255 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0256 */     SHFT,   SHFT,   SHFT,   SHFT,   SHFT,   SHFT,   SHFT,   SHFT,   /* Shift */
+/* 0257 */     CNTL,   CNTL,   CNTL,   CNTL,   CNTL,   CNTL,   CNTL,   CNTL,   /* Ctrl */
+/* 0260 */     LOCK,   LOCK,   LOCK,   LOCK,   LOCK,   LOCK,   LOCK,   LOCK,   /* Lock */
+/* 0261 */     SYMBOL, SYMBOL, SYMBOL, SYMBOL, SYMBOL, SYMBOL, SYMBOL, SYMBOL, /* Compose Character */
+/* 0262 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0263 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0264 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0265 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0266 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0267 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0270 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0271 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0272 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0273 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0274 */     0177,   0177,   0377,   0377,   0030,   0177,   0377,   0377,   /* back */
+/* 0275 */     '\r',   '\r',   0215,   0215,   '\r',   -1,     -1,     -1,     /* Return */
+/* 0276 */     '\t',   '\t',   0211,   0211,   '\t',   -1,     -1,     -1,     /* Tab */
+/* 0277 */     '`',    '~',    0340,   0376,   0036,   0036,   -1,     -1,     /* ` */
+/* 0300 */     '1',    '!',    0261,   0241,   '1',    '!',    -1,     -1,     /* 1 */
+/* 0301 */     'q',    'Q',    0361,   0321,   0021,   0021,   0221,   0221,   /* q */
+/* 0302 */     'a',    'A',    0341,   0301,   0001,   0001,   0201,   0201,   /* a */
+/* 0303 */     'z',    'Z',    0372,   0332,   0032,   0032,   0232,   0232,   /* z */
+/* 0304 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0305 */     '2',    '@',    0262,   0300,   0000,   0000,   0262,   0200,   /* 2 */
+/* 0306 */     'w',    'W',    0367,   0327,   0027,   0027,   0227,   0227,   /* w */
+/* 0307 */     's',    'S',    0363,   0323,   0023,   0023,   0223,   0223,   /* s */
+/* 0310 */     'x',    'X',    0370,   0330,   0030,   0030,   0230,   0230,   /* x */
+/* 0311 */     '<',    '>',    0274,   0276,   -1,     -1,     -1,     -1,     /* < */
+/* 0312 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0313 */     '3',    '#',    0263,   0243,   0033,   '#',    -1,     -1,     /* 3 */
+/* 0314 */     'e',    'E',    0345,   0305,   0005,   0005,   0205,   0205,   /* e */
+/* 0315 */     'd',    'D',    0344,   0304,   0004,   0004,   0204,   0204,   /* d */
+/* 0316 */     'c',    'C',    0343,   0303,   0003,   0003,   0203,   0203,   /* c */
+/* 0317 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0320 */     '4',    '$',    0264,   0244,   0034,   '$',    -1,     -1,     /* 4 */
+/* 0321 */     'r',    'R',    0362,   0322,   0022,   0022,   0222,   0222,   /* r */
+/* 0322 */     'f',    'F',    0346,   0306,   0006,   0006,   0206,   0206,   /* f */
+/* 0323 */     'v',    'V',    0366,   0326,   0026,   0026,   0226,   0226,   /* v */
+/* 0324 */     ' ',    ' ',    0240,   0240,   0000,   0000,   0200,   0200,   /* space */
+/* 0325 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0326 */     '5',    '%',    0265,   0245,   0035,   '%',    -1,     -1,     /* 5 */
+/* 0327 */     't',    'T',    0364,   0324,   0024,   0024,   0224,   0224,   /* t */
+/* 0330 */     'g',    'G',    0347,   0307,   0007,   0007,   0207,   0207,   /* g */
+/* 0331 */     'b',    'B',    0342,   0302,   0002,   0002,   0202,   0202,   /* b */
+/* 0332 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0333 */     '6',    '^',    0266,   0336,   0036,   0036,   -1,     -1,     /* 6 */
+/* 0334 */     'y',    'Y',    0371,   0331,   0031,   0031,   0231,   0231,   /* y */
+/* 0335 */     'h',    'H',    0350,   0310,   0010,   0010,   0210,   0210,   /* h */
+/* 0336 */     'n',    'N',    0356,   0316,   0016,   0016,   0216,   0216,   /* n */
+/* 0337 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0340 */     '7',    '&',    0267,   0246,   0037,   '&',    -1,     -1,     /* 7 */
+/* 0341 */     'u',    'U',    0365,   0325,   0025,   0025,   0225,   0225,   /* u */
+/* 0342 */     'j',    'J',    0352,   0312,   0012,   0012,   0212,   0212,   /* j */
+/* 0343 */     'm',    'M',    0355,   0315,   0015,   0015,   0215,   0215,   /* m */
+/* 0344 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0345 */     '8',    '*',    0270,   0252,   0177,   '*',    -1,     -1,     /* 8 */
+/* 0346 */     'i',    'I',    0351,   0311,   0011,   0011,   0211,   0211,   /* i */
+/* 0347 */     'k',    'K',    0353,   0313,   0013,   0013,   0213,   0213,   /* k */
+/* 0350 */     ',',    '<',    0254,   0274,   -1,     -1,     -1,     -1,     /* , */
+/* 0351 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0352 */     '9',    '(',    0271,   0250,   '9',    '(',    -1,     -1,     /* 9 */
+/* 0353 */     'o',    'O',    0357,   0317,   0017,   0017,   0217,   0217,   /* o */
+/* 0354 */     'l',    'L',    0354,   0314,   0014,   0014,   0214,   0214,   /* l */
+/* 0355 */     '.',    '>',    0256,   0276,   -1,     -1,     -1,     -1,     /* . */
+/* 0356 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0357 */     '0',    ')',    0260,   0251,   '0',    ')',    -1,     -1,     /* 0 */
+/* 0360 */     'p',    'P',    0360,   0320,   0020,   0020,   0220,   0220,   /* p */
+/* 0361 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0362 */     ';',    ':',    0273,   0272,   -1,     -1,     -1,     -1,     /* ; */
+/* 0363 */     '/',    '?',    0257,   0277,   0037,   0037,   0237,   0237,   /* / */
+/* 0364 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0365 */     '=',    '+',    0275,   0253,   -1,     -1,     -1,     -1,     /* = */
+/* 0366 */     ']',    '}',    0335,   0376,   0035,   0035,   0335,   0335,   /* ] */
+/* 0367 */     '\\',   '|',    0334,   0374,   0034,   0034,   0334,   0334,   /* \ */
+/* 0370 */     -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,     /*  */
+/* 0371 */     '-',    '_',    0255,   0337,   0037,   0037,   0337,   0337,   /* - */
+/* 0372 */     '[',    '{',    0333,   0373,   0033,   0033,   0333,   0333,   /* [ */
+/* 0373 */     '\'',   '"',    0247,   0242,   -1,     -1,     -1,     -1,     /* ' */
+};
diff --git a/usr/src/new/X/doc/Usenix/Makefile b/usr/src/new/X/doc/Usenix/Makefile
new file mode 100644 (file)
index 0000000..5d3951e
--- /dev/null
@@ -0,0 +1,33 @@
+# Copyright 1985, Massachusetts Institute of Technology
+# Makefile for the Xlib document.
+
+TROFF= psroff
+FILES= macros.t\
+       abstract.t\
+       x.t\
+       kernel.t\
+       memory.t\
+       fd.t\
+       pty.t\
+       startup.t\
+       naming.t\
+       rpc.t\
+       select.t\
+       summary.t\
+       ack.t\
+       references.t
+
+
+all:   paper
+
+paper: $(FILES)
+       cat $(FILES) |${TROFF} -ms
+
+cat: $(FILES)
+       cat $(FILES) >catfiles
+
+preview:$(FILES)
+       cat $(FILES) | nroff -ms | colcrt
+
+clean:
+       rm -f *~ \#* *.bak errs
diff --git a/usr/src/new/X/include/X/Xkeyboard.h b/usr/src/new/X/include/X/Xkeyboard.h
new file mode 120000 (symlink)
index 0000000..e441eeb
--- /dev/null
@@ -0,0 +1 @@
+../../Xlib/Xkeyboard.h
\ No newline at end of file
diff --git a/usr/src/new/X/include/X/Xtext.h b/usr/src/new/X/include/X/Xtext.h
new file mode 120000 (symlink)
index 0000000..131348e
--- /dev/null
@@ -0,0 +1 @@
+../../Xlib/Xtext.h
\ No newline at end of file
diff --git a/usr/src/new/X/include/X/Xtty.h b/usr/src/new/X/include/X/Xtty.h
new file mode 120000 (symlink)
index 0000000..ab6d0b8
--- /dev/null
@@ -0,0 +1 @@
+../../Xlib/Xtty.h
\ No newline at end of file
diff --git a/usr/src/new/X/keycomp/Makefile b/usr/src/new/X/keycomp/Makefile
new file mode 100644 (file)
index 0000000..677f542
--- /dev/null
@@ -0,0 +1,33 @@
+# Copyright 1985, Massachusetts Institute of Technology
+#
+#       - makefile for keycomp
+#
+
+DESTDIR =
+CONFDIR = /usr/new
+INCDIR = -I../include
+
+CFLAGS = -O ${INCDIR}
+XLIB = ../Xlib/libX.a
+SRCS = keycomp.c
+OBJS = keycomp.o
+PROGRAM = keycomp
+
+all: keycomp Xkeymap
+
+clean: 
+       rm -f *.bak *.o *~ $(PROGRAM) Xkeymap \#*
+
+Xkeymap: Xkeymap.default keycomp
+       keycomp <Xkeymap.default >Xkeymap
+
+install: all
+       install keycomp ${DESTDIR}${CONFDIR}
+       cp Xkeymap.default ${DESTDIR}/usr/lib/Xkeymap.txt
+       chmod 0644 ${DESTDIR}/usr/lib/Xkeymap.txt
+
+keycomp: keycomp.o ../Xlib/libX.a
+       cc $(CFLAGS) $(OBJS) -o $(PROGRAM) $(XLIB)
+
+$(OBJS): $(SRCS)
+
diff --git a/usr/src/new/X/keycomp/Xkeymap.default b/usr/src/new/X/keycomp/Xkeymap.default
new file mode 100644 (file)
index 0000000..4a1a834
--- /dev/null
@@ -0,0 +1,66 @@
+# Copyright 1985, Massachusetts Institute of Technology
+# $Header: Xkeymap.default,v 10.3 86/02/01 15:45:21 tony Rel $
+# This file contains the default keyboard mapping.  The first column contains a X keyboard code; the other
+# 16 columns contain the mapping of the keycode to a character string, with various combinations
+# of the SHIFT, LOCK, META, and CONTROL keys down.  See the man page for "keycomp" for more information.
+#
+# Keycode constants for non-typewriter keys are found in <X/Xkeyboard.h>.
+#
+# It is easiest to edit this file with an EMACS window running across the entire width of the display, with
+# tab stop set to 4.
+#
+0161   0033, 0033, 0033,       0033, 0033,     0033, 0033,     0033, 0033,     0033, 0033,     0033, 0033,     0033, 0033,     0033, /* F11/ESC */
+0162   '\b', '\b', '\b',       '\b', '\b',     '\b', U,        U,    '\b',     '\b', U,        U,    U,        U,    U,        U,    /* F12/BS */
+0163   '\n', '\n', '\n',       '\n', '\n',     '\n', U,        U,    '\n',     '\n', U,        U,    U,        U,    U,        U,    /* F13/LF */
+0274   0177, 0177, 0177,       0177, 0377,     0377, 0377,     0377, 0030,     0030, 0177,     0177, 0377,     0377, 0377,     0377, /* back */
+0275   '\r', '\r', '\r',       '\r', 0215,     0215, 0215,     0215, '\r',     '\r', U,        U,    U,        U,    U,        U,    /* Return */
+0276   '\t', '\t', '\t',       '\t', 0211,     0211, 0211,     0211, '\t',     '\t', U,        U,    U,        U,    U,        U,    /* Tab */
+0277   '`',  '`',  '~',        '~',  0340,     0340, 0376,     0376, 0036,     0036, 0036,     0036, U,        U,    U,        U,    /* ` */
+0300   '1',  '1',  '!',        '!',  0261,     0261, 0241,     0241, '1',      '1',  '!',      '!',  U,        U,    U,        U,    /* 1 */
+0301   'q',  'Q',  'Q',        'Q',  0361,     0361, 0321,     0321, 0021,     0021, 0021,     0021, 0221,     0221, 0221,     0221, /* q */
+0302   'a',  'A',  'A',        'A',  0341,     0341, 0301,     0301, 0001,     0001, 0001,     0001, 0201,     0201, 0201,     0201, /* a */
+0303   'z',  'Z',  'Z',        'Z',  0372,     0372, 0332,     0332, 0032,     0032, 0032,     0032, 0232,     0232, 0232,     0232, /* z */
+0305   '2',  '2',  '@',        '@',  0262,     0262, 0300,     0300, 0000,     0000, 0000,     0000, 0262,     0262, 0200,     0200, /* 2 */
+0306   'w',  'W',  'W',        'W',  0367,     0367, 0327,     0327, 0027,     0027, 0027,     0027, 0227,     0227, 0227,     0227, /* w */
+0307   's',  'S',  'S',        'S',  0363,     0363, 0323,     0323, 0023,     0023, 0023,     0023, 0223,     0223, 0223,     0223, /* s */
+0310   'x',  'X',  'X',        'X',  0370,     0370, 0330,     0330, 0030,     0030, 0030,     0030, 0230,     0230, 0230,     0230, /* x */
+0311   '<',  '<',  '>',        '>',  0274,     0274, 0276,     0276, U,        U,    U,        U,    U,        U,    U,        U,    /* < */
+0313   '3',  '3',  '#',        '#',  0263,     0263, 0243,     0243, 0033,     0033,  '#',     '#',  U,        U,    U,        U,    /* 3 */
+0314   'e',  'E',  'E',        'E',  0345,     0345, 0305,     0305, 0005,     0005, 0005,     0005, 0205,     0205, 0205,     0205, /* e */
+0315   'd',  'D',  'D',        'D',  0344,     0344, 0304,     0304, 0004,     0004, 0004,     0004, 0204,     0204, 0204,     0204, /* d */
+0316   'c',  'C',  'C',        'C',  0343,     0343, 0303,     0303, 0003,     0003, 0003,     0003, 0203,     0203, 0203,     0203, /* c */
+0320   '4',  '4',  '$',        '$',  0264,     0264, 0244,     0244, 0034,     0034,  '$',     '$',  U,        U,    U,        U,    /* 4 */
+0321   'r',  'R',  'R',        'R',  0362,     0362, 0322,     0322, 0022,     0022, 0022,     0022, 0222,     0222, 0222,     0222, /* r */
+0322   'f',  'F',  'F',        'F',  0346,     0346, 0306,     0306, 0006,     0006, 0006,     0006, 0206,     0206, 0206,     0206, /* f */
+0323   'v',  'V',  'V',        'V',  0366,     0366, 0326,     0326, 0026,     0026, 0026,     0026, 0226,     0226, 0226,     0226, /* v */
+0324   ' ',  ' ',  ' ',        ' ',  0240,     0240, 0240,     0240, 0000,     0000, 0000,     0000, 0200,     0200, 0200,     0200, /* space */
+0326   '5',  '5',  '%',        '%',  0265,     0265, 0245,     0245, 0035,     0035,  '%',     '%',  U,        U,    U,        U,    /* 5 */
+0327   't',  'T',  'T',        'T',  0364,     0364, 0324,     0324, 0024,     0024, 0024,     0024, 0224,     0224, 0224,     0224, /* t */
+0330   'g',  'G',  'G',        'G',  0347,     0347, 0307,     0307, 0007,     0007, 0007,     0007, 0207,     0207, 0207,     0207, /* g */
+0331   'b',  'B',  'B',        'B',  0342,     0342, 0302,     0302, 0002,     0002, 0002,     0002, 0202,     0202, 0202,     0202, /* b */
+0333   '6',  '6',  '^',        '^',  0266,     0266, 0336,     0336, 0036,     0036, 0036,     0036, U,        U,    U,        U,    /* 6 */
+0334   'y',  'Y',  'Y',        'Y',  0371,     0371, 0331,     0331, 0031,     0031, 0031,     0031, 0231,     0231, 0231,     0231, /* y */
+0335   'h',  'H',  'H',        'H',  0350,     0350, 0310,     0310, 0010,     0010, 0010,     0010, 0210,     0210, 0210,     0210, /* h */
+0336   'n',  'N',  'N',        'N',  0356,     0356, 0316,     0316, 0016,     0016, 0016,     0016, 0216,     0216, 0216,     0216, /* n */
+0340   '7',  '7',  '&',        '&',  0267,     0267, 0246,     0246, 0037,     0037,  '&',     '&',  U,        U,    U,        U,    /* 7 */
+0341   'u',  'U',  'U',        'U',  0365,     0365, 0325,     0325, 0025,     0025, 0025,     0025, 0225,     0225, 0225,     0225, /* u */
+0342   'j',  'J',  'J',        'J',  0352,     0352, 0312,     0312, 0012,     0012, 0012,     0012, 0212,     0212, 0212,     0212, /* j */
+0343   'm',  'M',  'M',        'M',  0355,     0355, 0315,     0315, 0015,     0015, 0015,     0015, 0215,     0215, 0215,     0215, /* m */
+0345   '8',  '8',  '*',        '*',  0270,     0270, 0252,     0252, 0177,     0177,  '*',     '*',  U,        U,    U,        U,    /* 8 */
+0346   'i',  'I',  'I',        'I',  0351,     0351, 0311,     0311, 0011,     0011, 0011,     0011, 0211,     0211, 0211,     0211, /* i */
+0347   'k',  'K',  'K',        'K',  0353,     0353, 0313,     0313, 0013,     0013, 0013,     0013, 0213,     0213, 0213,     0213, /* k */
+0350   ',',  ',',  '<',        '<',  0254,     0254, 0274,     0274, U,        U,    U,        U,    U,        U,    U,        U,    /* , */
+0352   '9',  '9',  '(',        '(',  0271,     0271, 0250,     0250, '9',      '9',  '(',      '(',  U,        U,    U,        U,    /* 9 */
+0353   'o',  'O',  'O',        'O',  0357,     0357, 0317,     0317, 0017,     0017, 0017,     0017, 0217,     0217, 0217,     0217, /* o */
+0354   'l',  'L',  'L',        'L',  0354,     0354, 0314,     0314, 0014,     0014, 0014,     0014, 0214,     0214, 0214,     0214, /* l */
+0355   '.',  '.',  '>',        '>',  0256,     0256, 0276,     0276, U,        U,    U,        U,    U,        U,    U,        U,    /* . */
+0357   '0',  '0',  ')',        ')',  0260,     0260, 0251,     0251, '0',      '0',  ')',      ')',  U,        U,    U,        U,    /* 0 */
+0360   'p',  'P',  'P',        'P',  0360,     0360, 0320,     0320, 0020,     0020, 0020,     0020, 0220,     0220, 0220,     0220, /* p */
+0362   ';',  ';',  ':',        ':',  0273,     0273, 0272,     0272, U,        U,    U,        U,    U,        U,    U,        U,    /* ; */
+0363   '/',  '/',  '?',        '?',  0257,     0257, 0277,     0277, 0037,     0037, 0037,     0037, 0237,     0237, 0237,     0237, /* / */
+0365   '=',  '=',  '+',        '+',  0275,     0275, 0253,     0253, U,        U,    U,        U,    U,        U,    U,        U,    /* = */
+0366   ']',  ']',  '}',        '}',  0335,     0335, 0376,     0376, 0035,     0035, 0035,     0035, 0335,     0335, 0335,     0335, /* ] */
+0367   '\\', '\\', '|',        '|',  0334,     0334, 0374,     0374, 0034,     0034, 0034,     0034, 0334,     0334, 0334,     0334, /* \ */
+0371   '-',  '-',  '_',        '_',  0255,     0255, 0337,     0337, 0037,     0037, 0037,     0037, 0337,     0337, 0337,     0337, /* - */
+0372   '[',  '[',  '{',        '{',  0333,     0333, 0373,     0373, 0033,     0033, 0033,     0033, 0333,     0333, 0333,     0333, /* [ */
+0373   '\'', '\'', '"',        '"',  0247,     0247, 0242,     0242, U,        U,    U,        U,    U,        U,    U,        U,    /* ' */
diff --git a/usr/src/new/X/keycomp/Xkeymap.h b/usr/src/new/X/keycomp/Xkeymap.h
new file mode 120000 (symlink)
index 0000000..3c20214
--- /dev/null
@@ -0,0 +1 @@
+../Xlib/Xkeymap.h
\ No newline at end of file
diff --git a/usr/src/new/X/keycomp/keycomp.c b/usr/src/new/X/keycomp/keycomp.c
new file mode 100644 (file)
index 0000000..3e80ca9
--- /dev/null
@@ -0,0 +1,333 @@
+#include <X/mit-copyright.h>
+
+/* Copyright 1985, Massachusetts Institute of Technology */
+
+#ifndef lint
+static char *rcsid_keycomp_c = "$Header: keycomp.c,v 10.5 86/05/29 15:55:47 newman Rel $";
+#endif
+
+#include <stdio.h>
+#include <X/X.h>
+#include "Xkeymap.h"
+
+#define isnum(c) (((c) >= '0') && ((c) <= '9'))
+#define isoctal(c) (((c) >= '0') && ((c) <= '7'))
+#define whitespace(c) (((c) == ' ' || (c) == '\t' || (c) == '\n' || (c) == '\0'))
+
+#define bool int
+#define TRUE 1
+#define FALSE 0
+
+#define MAXLENGTH 80
+
+typedef struct _EscMapEntry {
+    char from, to;} EscMapEntry;
+
+typedef enum _ParseError {
+    e_NoError,
+    e_NoKeycode,
+    e_KeycodeTooBig,
+    e_Not1Or16Items,
+    e_NotNumber,
+    e_NumberTooBig,
+    e_SingleQuoteNotClosed,
+    e_StringTooLong,
+    e_DoubleQuoteNotClosed,
+    e_TooManyCharsBetweenQuotes,
+    e_Unrecognized
+    } ParseError;
+
+#define CT_ESC_ENTRIES 5
+static EscMapEntry EscMap [CT_ESC_ENTRIES] = {
+    {'n', '\n'},
+    {'t', '\t'},
+    {'b', '\b'},
+    {'r', '\r'},
+    {'f', '\f'}} ;
+    
+static KeyMapElt keymap [256];    
+
+static int column_map[16] = 
+    {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+
+/*  the following variables are global to facilitate error-handling */
+static int line_no = 0, item_no = 0;
+
+/* the following variables are global to simplify initialization */
+char string_array [16][BUFSIZ];
+char *strings[16];
+
+main ()
+    {
+    char s[BUFSIZ];
+    int i, j;
+    char magic = X_KEYMAP_MAGIC;
+    /* seek past end of keymap (to beginning of extension) */
+    if (isatty(fileno(stdout)) 
+      || (fseek (stdout, sizeof (keymap)+1, 0) == -1)) {
+       /* "+1" above is because magic number is first byte in file */
+       fprintf (stderr, "Couldn't fseek output file\n");
+       exit (-1);
+       }
+    for (i=0;i<256;i++)
+       for (j=0;j<16;j++)
+           keymap[i][j] = UNBOUND;
+    for (i=0;i<16;i++)
+       strings[i] = string_array[i];
+    while (gets(s)) {
+       ProcessLine(s);
+       line_no++;
+       }
+    fseek (stdout, 0, 0);
+    if (!fwrite (&magic, 1, 1, stdout)
+       || !fwrite (keymap, sizeof(keymap), 1, stdout)) {
+       fprintf (stderr, "Error writing beginning of output file\n");
+       exit (-1);
+       }
+    exit(0);
+    }
+    
+ProcessLine (line)
+    char *line;
+    {
+    int lengths [MAXLENGTH];
+    int i=0, items, keycode;
+    char c;
+    if (line[0] == '#' || line[0] == '\0')
+       /* ignore comment lines (starting with '#') and blank lines */
+       return;
+    if (!isnum(line[0]))
+       Error(e_NoKeycode);  /* line must start with key code */
+    i++;
+    while (isnum(line[i]))
+       i++;
+    c = line[i];
+    line[i] = '\0';
+    sscanf (line, (line[0] == '0') ? "%o" : "%d", &keycode);
+    if (keycode > 255)
+       Error(e_KeycodeTooBig);
+    line[i] = c;
+    items = ScanForItems (&line[i], strings, lengths);
+    if (items == 1) {
+       unsigned char value;
+       int j;
+       if (lengths[0] == 0)
+           value = UNBOUND;
+       else if (lengths[0] > 1 || !SingleCharBound (strings[0][0])) {
+           value = EXTENSION_BOUND;
+           AddToExtension (keycode, DontCareMetaBits, strings[0], lengths[0]);
+           }
+       else
+           value = strings[0][0];
+       for (j=0;j<16;j++)
+           keymap[keycode][j] = value;
+       }
+    else if (items == 16) {
+       int j;
+       for (j=0;j<16;j++) {
+           unsigned char value;
+           if (lengths[j] == 0)
+               value = UNBOUND;
+           else if (lengths[j] > 1 || !SingleCharBound (strings[j][0])) {
+               value = EXTENSION_BOUND;
+               AddToExtension (keycode, column_map[j], strings[j], lengths[j]);
+               }
+           else 
+               value = strings[j][0];
+           keymap [keycode] [column_map[j]] = value;
+           }
+       }
+    else Error(e_Not1Or16Items);
+    }
+
+AddToExtension (keycode, metabits, string, length)
+    unsigned int keycode, metabits;
+    char *string;
+    int length;
+    {
+    ExtensionHeader header;
+    header.keycode = keycode;
+    header.metabits = metabits;
+    header.length = length;
+    if (!fwrite (&header, ExtensionHeaderSize, 1, stdout) ||
+       !fwrite (string, length, 1, stdout)) {
+           fprintf (stderr, "Error writing extension to output file\n");
+           exit (-3);
+           }
+    }
+
+int ScanForItems (line, items, lengths)
+    char *line;
+    char *items[16];
+    int lengths[16];
+    {
+    int i = 0;
+    item_no = 0;
+    while (1) {
+
+       /* skip over leading white space */
+       while (whitespace(line[i])) {
+           if (line[i] == '\0')
+               return (item_no);
+           i++;
+           }
+       
+       if (isnum(line[i])) {
+           char *begin_num = &line[i];
+           char c;
+
+           /* find end of number string */
+           while (c = line[++i], isnum (c))
+               /* this CANNOT be written isnum(line[++i]) because of side
+                * effect in expression passed to macro */
+               ;
+
+           /* temporarily put null character at end of number string */
+           c = line[i];
+           line[i] = '\0';
+           lengths [item_no] = TranslateNumber (begin_num, items[item_no]);
+           line[i] = c;
+           }
+
+       else switch (line[i]) {
+           case '#':
+               return(item_no);  /* rest of line is comment -- ignore it */
+
+           case 'U':   /* "U" means "unbound" */
+               lengths [item_no] = 0;
+               i++;  /* increment past the "U" character */
+               break;
+
+           case '\'':
+           case '"': /* something between quotes */ {
+               char c;
+               char *begin_quote = &line[i++];
+               bool backslash = FALSE;
+               while (1) 
+                   switch (c = line[i++]) {
+                       case '\0':
+                           Error ((*begin_quote == '\'')
+                               ? e_SingleQuoteNotClosed
+                               : e_DoubleQuoteNotClosed);
+                           break;
+                       case '\\':
+                           backslash = !backslash;
+                           break;
+                       default:
+                           if (c == *begin_quote && !backslash)
+                               goto out1;
+                           backslash = FALSE;
+                           break;
+                       }
+             out1:
+               c = line [i];
+               line[i] = '\0';
+               lengths[item_no] = TranslateQuote (begin_quote, items[item_no]);
+               if ((lengths[item_no] > 1) && (*begin_quote == '\''))
+                   Error (e_TooManyCharsBetweenQuotes);
+               line[i] = c;
+               break;
+               }
+
+           default:
+               Error(e_Unrecognized);
+               break;
+
+           }
+       
+       if (line[i] == ',')
+           i++;  /* ignore terminating comma */
+       if (!whitespace (line[i]))
+           Error(e_Unrecognized);
+       item_no++;
+       if (item_no == 16)
+           return (item_no);   /* ignore anything on line after 16th char */
+       }
+    
+    }
+
+int TranslateNumber (from, to)
+    char *from, *to;
+    {
+    int value;
+    sscanf (from, (from[0] == '0') ? "%o" : "%d", &value);
+    if (value > 255)
+       Error(e_NumberTooBig);
+    to[0] = value;
+    return (1);  /* length */
+    }
+
+
+int TranslateQuote (from, to)
+    char *from, *to;
+    {
+    int from_length = strlen (from);
+    int i, to_length = 0;
+    for (i=1;i<from_length-1;i++) {
+       if (to_length >= MAXLENGTH)
+           Error(e_StringTooLong);
+       if (from[i] == '\\') {
+           if (isoctal (from[i+1])) {
+               /* backslash followed by octal digits */
+               int digits = 1; /* how many successive digits (max 3) */
+               int value;
+               if (isoctal (from[i+2]))
+                   digits += (1 + isoctal (from[i+3]));
+               sscanf (from+i+1, "%3o", &value);
+               if (value > 255)
+                   Error(e_NumberTooBig);
+               to[to_length++] = value;
+               i += digits;
+               }
+           else {
+               /* backslash followed by non-number */
+               int j;
+               for (j=0;j<CT_ESC_ENTRIES;j++)
+                   if (EscMap[j].from == from[i+1]) {
+                       to[to_length++] = EscMap[j].to;
+                       goto out;
+                       }
+               to[to_length++] = from[i+1];
+             out:
+               i++;
+               }
+           }
+       else
+           /* not a backslash, just an ordinary character */
+           to[to_length++] = from[i];
+       }
+    return (to_length);
+    }
+
+Error (type)
+    ParseError type;
+    {
+    char *s;
+    switch (type) {
+       case e_NoKeycode:
+           s = "Line doesn't begin with keycode"; break;
+       case e_KeycodeTooBig:
+           s = "Keycode is too big"; break;
+       case e_Not1Or16Items:
+           s = "Line doesn't have 1 or 16 entries"; break;
+       case e_NotNumber:
+           s = "Non-number found after backslash in char constant"; break;
+       case e_NumberTooBig:
+           s = "Number after backslash is too big for a char constant"; break;
+       case e_SingleQuoteNotClosed:
+           s = "Closing single quote not found"; break;
+       case e_StringTooLong:
+           s = "String is too long"; break;
+       case e_DoubleQuoteNotClosed:
+           s = "Closing double quote not found"; break;
+       case e_TooManyCharsBetweenQuotes:
+           s = "Too many characters for single character constant"; break;
+       case e_Unrecognized:
+           s = "Not a U, number, single- or double-quoted string"; break;
+       default:
+           s = "Unknown error";  break;
+       }
+    fprintf (stderr, "Parse error at item %d on line %d:\n\t %s\n",
+       item_no+1, line_no+1, s);
+    exit (type);
+    }