summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKaleb Keithley <kaleb@freedesktop.org>2003-11-14 15:54:30 +0000
committerKaleb Keithley <kaleb@freedesktop.org>2003-11-14 15:54:30 +0000
commitdeae12c6b683898f5213992d561a59d4ea889cca (patch)
tree3ed14c7b76f47ec80c1868c34bd0e5de385db618 /src
R6.6 is the Xorg base-lineXORG-MAIN
Diffstat (limited to 'src')
-rw-r--r--src/AllCells.c63
-rw-r--r--src/AllPlanes.c70
-rw-r--r--src/AllowEv.c48
-rw-r--r--src/AutoRep.c48
-rw-r--r--src/Backgnd.c46
-rw-r--r--src/BdrWidth.c50
-rw-r--r--src/Bell.c43
-rw-r--r--src/Border.c46
-rw-r--r--src/ChAccCon.c58
-rw-r--r--src/ChActPGb.c46
-rw-r--r--src/ChClMode.c44
-rw-r--r--src/ChCmap.c46
-rw-r--r--src/ChGC.c48
-rw-r--r--src/ChKeyCon.c80
-rw-r--r--src/ChPntCon.c50
-rw-r--r--src/ChProp.c107
-rw-r--r--src/ChSaveSet.c58
-rw-r--r--src/ChWAttrs.c55
-rw-r--r--src/ChWindow.c59
-rw-r--r--src/ChkIfEv.c83
-rw-r--r--src/ChkMaskEv.c90
-rw-r--r--src/ChkTypEv.c75
-rw-r--r--src/ChkTypWEv.c77
-rw-r--r--src/ChkWinEv.c91
-rw-r--r--src/CirWin.c45
-rw-r--r--src/CirWinDn.c44
-rw-r--r--src/CirWinUp.c44
-rw-r--r--src/ClDisplay.c70
-rw-r--r--src/Clear.c46
-rw-r--r--src/ClearArea.c51
-rw-r--r--src/ConfWind.c66
-rw-r--r--src/ConnDis.c1157
-rw-r--r--src/Context.c317
-rw-r--r--src/ConvSel.c49
-rw-r--r--src/CopyArea.c59
-rw-r--r--src/CopyCmap.c49
-rw-r--r--src/CopyGC.c134
-rw-r--r--src/CopyPlane.c61
-rw-r--r--src/CrBFData.c85
-rw-r--r--src/CrCmap.c53
-rw-r--r--src/CrCursor.c57
-rw-r--r--src/CrGC.c342
-rw-r--r--src/CrGlCur.c59
-rw-r--r--src/CrPFBData.c83
-rw-r--r--src/CrPixmap.c49
-rw-r--r--src/CrWindow.c74
-rw-r--r--src/Cursor.c51
-rw-r--r--src/DefCursor.c46
-rw-r--r--src/DelProp.c44
-rw-r--r--src/Depths.c60
-rw-r--r--src/DestSubs.c42
-rw-r--r--src/DestWind.c42
-rw-r--r--src/DisName.c62
-rw-r--r--src/DrArc.c79
-rw-r--r--src/DrArcs.c54
-rw-r--r--src/DrLine.c95
-rw-r--r--src/DrLines.c54
-rw-r--r--src/DrPoint.c93
-rw-r--r--src/DrPoints.c82
-rw-r--r--src/DrRect.c95
-rw-r--r--src/DrRects.c62
-rw-r--r--src/DrSegs.c63
-rw-r--r--src/ErrDes.c196
-rw-r--r--src/ErrHndlr.c95
-rw-r--r--src/EvToWire.c404
-rw-r--r--src/FSSaver.c60
-rw-r--r--src/FSWrap.c273
-rw-r--r--src/FetchName.c93
-rw-r--r--src/FillArc.c96
-rw-r--r--src/FillArcs.c64
-rw-r--r--src/FillPoly.c61
-rw-r--r--src/FillRct.c92
-rw-r--r--src/FillRcts.c63
-rw-r--r--src/FilterEv.c104
-rw-r--r--src/Flush.c40
-rw-r--r--src/Font.c241
-rw-r--r--src/FontInfo.c248
-rw-r--r--src/FontNames.c118
-rw-r--r--src/FreeCmap.c46
-rw-r--r--src/FreeCols.c54
-rw-r--r--src/FreeCurs.c41
-rw-r--r--src/FreeEData.c43
-rw-r--r--src/FreeGC.c47
-rw-r--r--src/FreePix.c42
-rw-r--r--src/GCMisc.c103
-rw-r--r--src/Geom.c98
-rw-r--r--src/GetAtomNm.c204
-rw-r--r--src/GetColor.c111
-rw-r--r--src/GetDflt.c247
-rw-r--r--src/GetFPath.c90
-rw-r--r--src/GetFProp.c53
-rw-r--r--src/GetGCVals.c126
-rw-r--r--src/GetGeom.c58
-rw-r--r--src/GetHColor.c57
-rw-r--r--src/GetHints.c337
-rw-r--r--src/GetIFocus.c47
-rw-r--r--src/GetImage.c122
-rw-r--r--src/GetKCnt.c53
-rw-r--r--src/GetMoEv.c83
-rw-r--r--src/GetNrmHint.c125
-rw-r--r--src/GetPCnt.c49
-rw-r--r--src/GetPntMap.c127
-rw-r--r--src/GetProp.c129
-rw-r--r--src/GetRGBCMap.c133
-rw-r--r--src/GetSOwner.c44
-rw-r--r--src/GetSSaver.c52
-rw-r--r--src/GetStCmap.c115
-rw-r--r--src/GetTxtProp.c111
-rw-r--r--src/GetWAttrs.c144
-rw-r--r--src/GetWMCMapW.c85
-rw-r--r--src/GetWMProto.c85
-rw-r--r--src/GrButton.c57
-rw-r--r--src/GrKey.c55
-rw-r--r--src/GrKeybd.c56
-rw-r--r--src/GrPointer.c63
-rw-r--r--src/GrServer.c40
-rw-r--r--src/Host.c91
-rw-r--r--src/Iconify.c84
-rw-r--r--src/IfEvent.c72
-rw-r--r--src/ImText.c109
-rw-r--r--src/ImText16.c111
-rw-r--r--src/ImUtil.c1016
-rw-r--r--src/InitExt.c473
-rw-r--r--src/InsCmap.c41
-rw-r--r--src/IntAtom.c319
-rw-r--r--src/KeyBind.c731
-rw-r--r--src/KeysymStr.c137
-rw-r--r--src/KillCl.c41
-rw-r--r--src/LiHosts.c100
-rw-r--r--src/LiICmaps.c70
-rw-r--r--src/LiProps.c68
-rw-r--r--src/ListExt.c96
-rw-r--r--src/LoadFont.c54
-rw-r--r--src/LockDis.c90
-rw-r--r--src/LookupCol.c104
-rw-r--r--src/LowerWin.c46
-rw-r--r--src/Macros.c250
-rw-r--r--src/MapRaised.c48
-rw-r--r--src/MapSubs.c40
-rw-r--r--src/MapWindow.c41
-rw-r--r--src/MaskEvent.c80
-rw-r--r--src/Misc.c67
-rw-r--r--src/ModMap.c198
-rw-r--r--src/MoveWin.c61
-rw-r--r--src/NextEvent.c52
-rw-r--r--src/OCWrap.c161
-rw-r--r--src/OMWrap.c152
-rw-r--r--src/OpenDis.c760
-rw-r--r--src/ParseCmd.c234
-rw-r--r--src/ParseCol.c135
-rw-r--r--src/ParseGeom.c186
-rw-r--r--src/PeekEvent.c48
-rw-r--r--src/PeekIfEv.c73
-rw-r--r--src/Pending.c57
-rw-r--r--src/PixFormats.c60
-rw-r--r--src/PmapBgnd.c45
-rw-r--r--src/PmapBord.c45
-rw-r--r--src/PolyReg.c630
-rw-r--r--src/PolyTxt.c230
-rw-r--r--src/PolyTxt16.c264
-rw-r--r--src/PropAlloc.c73
-rw-r--r--src/PutBEvent.c59
-rw-r--r--src/PutImage.c998
-rw-r--r--src/QuBest.c58
-rw-r--r--src/QuColor.c59
-rw-r--r--src/QuColors.c75
-rw-r--r--src/QuCurShp.c57
-rw-r--r--src/QuExt.c63
-rw-r--r--src/QuKeybd.c52
-rw-r--r--src/QuPntr.c60
-rw-r--r--src/QuStipShp.c57
-rw-r--r--src/QuTextE16.c91
-rw-r--r--src/QuTextExt.c90
-rw-r--r--src/QuTileShp.c58
-rw-r--r--src/QuTree.c71
-rw-r--r--src/Quarks.c431
-rw-r--r--src/RaiseWin.c46
-rw-r--r--src/RdBitF.c289
-rw-r--r--src/RecolorC.c50
-rw-r--r--src/ReconfWM.c139
-rw-r--r--src/ReconfWin.c78
-rw-r--r--src/Region.c1672
-rw-r--r--src/RegstFlt.c160
-rw-r--r--src/RepWindow.c47
-rw-r--r--src/RestackWs.c67
-rw-r--r--src/RotProp.c60
-rw-r--r--src/ScrResStr.c54
-rw-r--r--src/SelInput.c46
-rw-r--r--src/SendEvent.c73
-rw-r--r--src/SetBack.c43
-rw-r--r--src/SetCRects.c79
-rw-r--r--src/SetClMask.c44
-rw-r--r--src/SetClOrig.c49
-rw-r--r--src/SetDashes.c61
-rw-r--r--src/SetFPath.c75
-rw-r--r--src/SetFont.c44
-rw-r--r--src/SetFore.c43
-rw-r--r--src/SetFunc.c43
-rw-r--r--src/SetHints.c296
-rw-r--r--src/SetIFocus.c47
-rw-r--r--src/SetLStyle.c60
-rw-r--r--src/SetLocale.c230
-rw-r--r--src/SetNrmHint.c108
-rw-r--r--src/SetPMask.c43
-rw-r--r--src/SetPntMap.c84
-rw-r--r--src/SetRGBCMap.c98
-rw-r--r--src/SetSOwner.c46
-rw-r--r--src/SetSSaver.c47
-rw-r--r--src/SetStCmap.c90
-rw-r--r--src/SetState.c60
-rw-r--r--src/SetStip.c43
-rw-r--r--src/SetTSOrig.c49
-rw-r--r--src/SetTile.c43
-rw-r--r--src/SetTxtProp.c91
-rw-r--r--src/SetWMCMapW.c72
-rw-r--r--src/SetWMProto.c72
-rw-r--r--src/StBytes.c114
-rw-r--r--src/StColor.c67
-rw-r--r--src/StColors.c62
-rw-r--r--src/StNColor.c92
-rw-r--r--src/StName.c63
-rw-r--r--src/StrKeysym.c148
-rw-r--r--src/StrToText.c88
-rw-r--r--src/Sync.c59
-rw-r--r--src/Synchro.c96
-rw-r--r--src/Text.c146
-rw-r--r--src/Text16.c159
-rw-r--r--src/TextExt.c252
-rw-r--r--src/TextExt16.c228
-rw-r--r--src/TextToStr.c115
-rw-r--r--src/TrCoords.c61
-rw-r--r--src/UndefCurs.c46
-rw-r--r--src/UngrabBut.c46
-rw-r--r--src/UngrabKbd.c42
-rw-r--r--src/UngrabKey.c50
-rw-r--r--src/UngrabPtr.c41
-rw-r--r--src/UngrabSvr.c41
-rw-r--r--src/UninsCmap.c41
-rw-r--r--src/UnldFont.c42
-rw-r--r--src/UnmapSubs.c41
-rw-r--r--src/UnmapWin.c42
-rw-r--r--src/VisUtil.c253
-rw-r--r--src/WMGeom.c195
-rw-r--r--src/WMProps.c132
-rw-r--r--src/WarpPtr.c54
-rw-r--r--src/WinEvent.c84
-rw-r--r--src/Window.c136
-rw-r--r--src/Withdraw.c81
-rw-r--r--src/WrBitF.c159
-rw-r--r--src/XErrorDB737
-rw-r--r--src/XKeysymDB206
-rw-r--r--src/Xatomtype.h134
-rw-r--r--src/XlibAsync.c153
-rw-r--r--src/XlibInt.c3424
-rw-r--r--src/XomGeneric.h181
-rw-r--r--src/Xrm.c2667
-rw-r--r--src/XrmI.h47
-rw-r--r--src/evtomask.c78
-rw-r--r--src/globals.c235
-rw-r--r--src/imConv.c897
-rw-r--r--src/locking.c642
-rw-r--r--src/locking.h173
-rw-r--r--src/poly.h295
-rw-r--r--src/udcInf.c711
-rw-r--r--src/util/makekeys.c259
-rw-r--r--src/util/mkks.sh11
-rw-r--r--src/xcms/AddDIC.c156
-rw-r--r--src/xcms/AddSF.c155
-rw-r--r--src/xcms/CCC.c287
-rw-r--r--src/xcms/CvColW.c139
-rw-r--r--src/xcms/CvCols.c1048
-rw-r--r--src/xcms/HVC.c611
-rw-r--r--src/xcms/HVCGcC.c153
-rw-r--r--src/xcms/HVCGcV.c206
-rw-r--r--src/xcms/HVCGcVC.c267
-rw-r--r--src/xcms/HVCMnV.c167
-rw-r--r--src/xcms/HVCMxC.c247
-rw-r--r--src/xcms/HVCMxV.c250
-rw-r--r--src/xcms/HVCMxVC.c244
-rw-r--r--src/xcms/HVCMxVs.c166
-rw-r--r--src/xcms/HVCWpAj.c118
-rw-r--r--src/xcms/IdOfPr.c111
-rw-r--r--src/xcms/LRGB.c1813
-rw-r--r--src/xcms/Lab.c416
-rw-r--r--src/xcms/LabGcC.c124
-rw-r--r--src/xcms/LabGcL.c176
-rw-r--r--src/xcms/LabGcLC.c225
-rw-r--r--src/xcms/LabMnL.c218
-rw-r--r--src/xcms/LabMxC.c205
-rw-r--r--src/xcms/LabMxL.c218
-rw-r--r--src/xcms/LabMxLC.c226
-rw-r--r--src/xcms/LabWpAj.c97
-rw-r--r--src/xcms/Luv.c385
-rw-r--r--src/xcms/LuvGcC.c124
-rw-r--r--src/xcms/LuvGcL.c176
-rw-r--r--src/xcms/LuvGcLC.c225
-rw-r--r--src/xcms/LuvMnL.c218
-rw-r--r--src/xcms/LuvMxC.c205
-rw-r--r--src/xcms/LuvMxL.c218
-rw-r--r--src/xcms/LuvMxLC.c226
-rw-r--r--src/xcms/LuvWpAj.c100
-rw-r--r--src/xcms/OfCCC.c160
-rw-r--r--src/xcms/PrOfId.c107
-rw-r--r--src/xcms/QBlack.c82
-rw-r--r--src/xcms/QBlue.c82
-rw-r--r--src/xcms/QGreen.c82
-rw-r--r--src/xcms/QRed.c82
-rw-r--r--src/xcms/QWhite.c82
-rw-r--r--src/xcms/QuCol.c76
-rw-r--r--src/xcms/QuCols.c75
-rw-r--r--src/xcms/SetCCC.c150
-rw-r--r--src/xcms/SetGetCols.c201
-rw-r--r--src/xcms/StCol.c79
-rw-r--r--src/xcms/StCols.c110
-rw-r--r--src/xcms/UNDEFINED.c102
-rw-r--r--src/xcms/XRGB.c245
-rw-r--r--src/xcms/XYZ.c192
-rw-r--r--src/xcms/Xcms.txt61
-rw-r--r--src/xcms/Xcmsint.h246
-rw-r--r--src/xcms/cmsAllCol.c71
-rw-r--r--src/xcms/cmsAllNCol.c214
-rw-r--r--src/xcms/cmsCmap.c492
-rw-r--r--src/xcms/cmsColNm.c1049
-rw-r--r--src/xcms/cmsGlobls.c160
-rw-r--r--src/xcms/cmsInt.c420
-rw-r--r--src/xcms/cmsLkCol.c213
-rw-r--r--src/xcms/cmsMath.c138
-rw-r--r--src/xcms/cmsProp.c143
-rw-r--r--src/xcms/cmsTrig.c600
-rw-r--r--src/xcms/uvY.c409
-rw-r--r--src/xcms/xyY.c381
-rw-r--r--src/xkb/XKB.c926
-rw-r--r--src/xkb/XKBAlloc.c587
-rw-r--r--src/xkb/XKBBell.c231
-rw-r--r--src/xkb/XKBBind.c963
-rw-r--r--src/xkb/XKBCompat.c277
-rw-r--r--src/xkb/XKBCtrls.c418
-rw-r--r--src/xkb/XKBCvt.c642
-rw-r--r--src/xkb/XKBExtDev.c953
-rw-r--r--src/xkb/XKBGAlloc.c1377
-rw-r--r--src/xkb/XKBGeom.c779
-rw-r--r--src/xkb/XKBGetByName.c231
-rw-r--r--src/xkb/XKBGetMap.c975
-rw-r--r--src/xkb/XKBList.c273
-rw-r--r--src/xkb/XKBMAlloc.c1077
-rw-r--r--src/xkb/XKBMisc.c1071
-rw-r--r--src/xkb/XKBNames.c953
-rw-r--r--src/xkb/XKBRdBuf.c322
-rw-r--r--src/xkb/XKBSetGeom.c561
-rw-r--r--src/xkb/XKBSetMap.c716
-rw-r--r--src/xkb/XKBUse.c837
-rw-r--r--src/xkb/XKBleds.c408
-rw-r--r--src/xkb/XKBlibint.h406
-rw-r--r--src/xlibi18n/ICWrap.c475
-rw-r--r--src/xlibi18n/IMWrap.c218
-rw-r--r--src/xlibi18n/XDefaultIMIF.c501
-rw-r--r--src/xlibi18n/XDefaultOMIF.c1372
-rw-r--r--src/xlibi18n/Xaixlcint.h54
-rw-r--r--src/xlibi18n/XimImSw.h53
-rw-r--r--src/xlibi18n/XimProto.h227
-rw-r--r--src/xlibi18n/XimThai.h201
-rw-r--r--src/xlibi18n/XimTrInt.h73
-rw-r--r--src/xlibi18n/XimTrX.h67
-rw-r--r--src/xlibi18n/XimTrans.h127
-rw-r--r--src/xlibi18n/Ximint.h1144
-rw-r--r--src/xlibi18n/XimintL.h78
-rw-r--r--src/xlibi18n/XimintP.h301
-rw-r--r--src/xlibi18n/XlcDL.c650
-rw-r--r--src/xlibi18n/XlcGeneric.h146
-rw-r--r--src/xlibi18n/XlcPubI.h252
-rw-r--r--src/xlibi18n/XlcPublic.h287
-rw-r--r--src/xlibi18n/XlcSL.c79
-rw-r--r--src/xlibi18n/Xlcint.h1003
-rw-r--r--src/xlibi18n/lcCT.c909
-rw-r--r--src/xlibi18n/lcCharSet.c164
-rw-r--r--src/xlibi18n/lcConv.c332
-rw-r--r--src/xlibi18n/lcDB.c1281
-rw-r--r--src/xlibi18n/lcDynamic.c74
-rw-r--r--src/xlibi18n/lcFile.c417
-rw-r--r--src/xlibi18n/lcGeneric.c1185
-rw-r--r--src/xlibi18n/lcInit.c229
-rw-r--r--src/xlibi18n/lcPrTxt.c252
-rw-r--r--src/xlibi18n/lcPubWrap.c104
-rw-r--r--src/xlibi18n/lcPublic.c308
-rw-r--r--src/xlibi18n/lcRM.c122
-rw-r--r--src/xlibi18n/lcStd.c305
-rw-r--r--src/xlibi18n/lcTxtPr.c235
-rw-r--r--src/xlibi18n/lcUtil.c78
-rw-r--r--src/xlibi18n/lcWrap.c620
-rw-r--r--src/xlibi18n/mbWMProps.c84
-rw-r--r--src/xlibi18n/mbWrap.c220
-rw-r--r--src/xlibi18n/wcWrap.c218
392 files changed, 86220 insertions, 0 deletions
diff --git a/src/AllCells.c b/src/AllCells.c
new file mode 100644
index 00000000..495d9a36
--- /dev/null
+++ b/src/AllCells.c
@@ -0,0 +1,63 @@
+/* $Xorg: AllCells.c,v 1.4 2001/02/09 02:03:30 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+
+#include "Xlibint.h"
+
+Status XAllocColorCells(dpy, cmap, contig, masks, nplanes, pixels, ncolors)
+register Display *dpy;
+Colormap cmap;
+Bool contig;
+unsigned int ncolors; /* CARD16 */
+unsigned int nplanes; /* CARD16 */
+unsigned long *masks; /* LISTofCARD32 */ /* RETURN */
+unsigned long *pixels; /* LISTofCARD32 */ /* RETURN */
+{
+
+ Status status;
+ xAllocColorCellsReply rep;
+ register xAllocColorCellsReq *req;
+ LockDisplay(dpy);
+ GetReq(AllocColorCells, req);
+
+ req->cmap = cmap;
+ req->colors = ncolors;
+ req->planes = nplanes;
+ req->contiguous = contig;
+
+ status = _XReply(dpy, (xReply *)&rep, 0, xFalse);
+
+ if (status) {
+ _XRead32 (dpy, (long *) pixels, 4L * (long) (rep.nPixels));
+ _XRead32 (dpy, (long *) masks, 4L * (long) (rep.nMasks));
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(status);
+}
diff --git a/src/AllPlanes.c b/src/AllPlanes.c
new file mode 100644
index 00000000..b636159e
--- /dev/null
+++ b/src/AllPlanes.c
@@ -0,0 +1,70 @@
+/* $Xorg: AllPlanes.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+Status XAllocColorPlanes(dpy, cmap, contig, pixels, ncolors, nreds, ngreens,
+ nblues, rmask, gmask, bmask)
+register Display *dpy;
+Colormap cmap;
+Bool contig;
+unsigned long *pixels; /* LISTofCARD32 */ /* RETURN */
+int ncolors;
+int nreds, ngreens, nblues;
+unsigned long *rmask, *gmask, *bmask; /* CARD32 */ /* RETURN */
+{
+ xAllocColorPlanesReply rep;
+ Status status;
+ register xAllocColorPlanesReq *req;
+
+ LockDisplay(dpy);
+ GetReq(AllocColorPlanes,req);
+
+ req->cmap = cmap;
+ req->colors = ncolors;
+ req->red = nreds;
+ req->green = ngreens;
+ req->blue = nblues;
+ req->contiguous = contig;
+
+ status = _XReply(dpy, (xReply *)&rep, 0, xFalse);
+
+
+ if (status) {
+ *rmask = rep.redMask;
+ *gmask = rep.greenMask;
+ *bmask = rep.blueMask;
+
+ /* sizeof(CARD32) = 4 */
+ _XRead32 (dpy, (char *) pixels, (long)(ncolors * 4));
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(status);
+}
diff --git a/src/AllowEv.c b/src/AllowEv.c
new file mode 100644
index 00000000..b12e8f61
--- /dev/null
+++ b/src/AllowEv.c
@@ -0,0 +1,48 @@
+/* $Xorg: AllowEv.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XAllowEvents(dpy, mode, time)
+ register Display *dpy;
+ int mode;
+ Time time;
+
+{
+ register xAllowEventsReq *req;
+
+ LockDisplay(dpy);
+ GetReq(AllowEvents,req);
+ req->mode = mode;
+ req->time = time;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+
+
diff --git a/src/AutoRep.c b/src/AutoRep.c
new file mode 100644
index 00000000..beb9a8f1
--- /dev/null
+++ b/src/AutoRep.c
@@ -0,0 +1,48 @@
+/* $Xorg: AutoRep.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1985, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XAutoRepeatOn (dpy)
+register Display *dpy;
+{
+ XKeyboardControl values;
+ values.auto_repeat_mode = AutoRepeatModeOn;
+ XChangeKeyboardControl (dpy, KBAutoRepeatMode, &values);
+ return 1;
+}
+
+XAutoRepeatOff (dpy)
+register Display *dpy;
+{
+ XKeyboardControl values;
+ values.auto_repeat_mode = AutoRepeatModeOff;
+ XChangeKeyboardControl (dpy, KBAutoRepeatMode, &values);
+ return 1;
+}
+
+
diff --git a/src/Backgnd.c b/src/Backgnd.c
new file mode 100644
index 00000000..e5b67666
--- /dev/null
+++ b/src/Backgnd.c
@@ -0,0 +1,46 @@
+/* $Xorg: Backgnd.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XSetWindowBackground(dpy, w, pixel)
+ register Display *dpy;
+ Window w;
+ unsigned long pixel;
+{
+ register xChangeWindowAttributesReq *req;
+
+ LockDisplay(dpy);
+ GetReqExtra (ChangeWindowAttributes, 4, req);
+ req->window = w;
+ req->valueMask = CWBackPixel;
+ OneDataCard32 (dpy, NEXTPTR(req,xChangeWindowAttributesReq), pixel);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/BdrWidth.c b/src/BdrWidth.c
new file mode 100644
index 00000000..2550fda3
--- /dev/null
+++ b/src/BdrWidth.c
@@ -0,0 +1,50 @@
+/* $Xorg: BdrWidth.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+
+/*
+
+Copyright 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XSetWindowBorderWidth(dpy, w, width)
+Display *dpy;
+Window w;
+unsigned int width;
+{
+ unsigned long lwidth = width; /* must be CARD32 */
+
+ register xConfigureWindowReq *req;
+ LockDisplay(dpy);
+ GetReqExtra(ConfigureWindow, 4, req);
+ req->window = w;
+ req->mask = CWBorderWidth;
+ OneDataCard32 (dpy, NEXTPTR(req,xConfigureWindowReq), lwidth);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/Bell.c b/src/Bell.c
new file mode 100644
index 00000000..7c620206
--- /dev/null
+++ b/src/Bell.c
@@ -0,0 +1,43 @@
+/* $Xorg: Bell.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XBell(dpy, percent)
+ register Display *dpy;
+ int percent;
+{
+ register xBellReq *req;
+
+ LockDisplay(dpy);
+ GetReq(Bell,req);
+ req->percent = percent;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/Border.c b/src/Border.c
new file mode 100644
index 00000000..5e71ee90
--- /dev/null
+++ b/src/Border.c
@@ -0,0 +1,46 @@
+/* $Xorg: Border.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XSetWindowBorder(dpy, w, pixel)
+ register Display *dpy;
+ Window w;
+ unsigned long pixel;
+{
+ register xChangeWindowAttributesReq *req;
+
+ LockDisplay(dpy);
+ GetReqExtra (ChangeWindowAttributes, 4, req);
+ req->window = w;
+ req->valueMask = CWBorderPixel;
+ OneDataCard32 (dpy, NEXTPTR(req,xChangeWindowAttributesReq), pixel);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/ChAccCon.c b/src/ChAccCon.c
new file mode 100644
index 00000000..4366f695
--- /dev/null
+++ b/src/ChAccCon.c
@@ -0,0 +1,58 @@
+/* $Xorg: ChAccCon.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XEnableAccessControl(dpy)
+ register Display *dpy;
+
+{
+ return XSetAccessControl(dpy, EnableAccess);
+}
+
+XDisableAccessControl(dpy)
+ register Display *dpy;
+
+{
+ return XSetAccessControl(dpy, DisableAccess);
+}
+
+XSetAccessControl(dpy, mode)
+ register Display *dpy;
+ int mode;
+
+{
+ register xSetAccessControlReq *req;
+
+ LockDisplay(dpy);
+ GetReq(SetAccessControl, req);
+ req->mode = mode;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/ChActPGb.c b/src/ChActPGb.c
new file mode 100644
index 00000000..adc2036e
--- /dev/null
+++ b/src/ChActPGb.c
@@ -0,0 +1,46 @@
+/* $Xorg: ChActPGb.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XChangeActivePointerGrab(dpy, event_mask, curs, time)
+register Display *dpy;
+unsigned int event_mask; /* CARD16 */
+Cursor curs;
+Time time;
+{
+ register xChangeActivePointerGrabReq *req;
+
+ LockDisplay(dpy);
+ GetReq(ChangeActivePointerGrab, req);
+ req->eventMask = event_mask;
+ req->cursor = curs;
+ req->time = time;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/ChClMode.c b/src/ChClMode.c
new file mode 100644
index 00000000..0b2657eb
--- /dev/null
+++ b/src/ChClMode.c
@@ -0,0 +1,44 @@
+/* $Xorg: ChClMode.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XSetCloseDownMode(dpy, mode)
+ register Display *dpy;
+ int mode;
+
+{
+ register xSetCloseDownModeReq *req;
+
+ LockDisplay(dpy);
+ GetReq(SetCloseDownMode, req);
+ req->mode = mode;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/ChCmap.c b/src/ChCmap.c
new file mode 100644
index 00000000..d6aaa892
--- /dev/null
+++ b/src/ChCmap.c
@@ -0,0 +1,46 @@
+/* $Xorg: ChCmap.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XSetWindowColormap(dpy, w, colormap)
+ register Display *dpy;
+ Window w;
+ Colormap colormap;
+{
+ register xChangeWindowAttributesReq *req;
+
+ LockDisplay(dpy);
+ GetReqExtra (ChangeWindowAttributes, 4, req);
+ req->window = w;
+ req->valueMask = CWColormap;
+ OneDataCard32 (dpy, NEXTPTR(req,xChangeWindowAttributesReq), colormap);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/ChGC.c b/src/ChGC.c
new file mode 100644
index 00000000..d7d536a6
--- /dev/null
+++ b/src/ChGC.c
@@ -0,0 +1,48 @@
+/* $Xorg: ChGC.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XChangeGC (dpy, gc, valuemask, values)
+ register Display *dpy;
+ GC gc;
+ unsigned long valuemask;
+ XGCValues *values;
+{
+ LockDisplay(dpy);
+
+ valuemask &= (1L << (GCLastBit + 1)) - 1;
+ if (valuemask) _XUpdateGCCache (gc, valuemask, values);
+
+ /* if any Resource ID changed, must flush */
+ if (gc->dirty & (GCFont | GCTile | GCStipple))
+ _XFlushGCCache(dpy, gc);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/ChKeyCon.c b/src/ChKeyCon.c
new file mode 100644
index 00000000..c1b3fdce
--- /dev/null
+++ b/src/ChKeyCon.c
@@ -0,0 +1,80 @@
+/* $Xorg: ChKeyCon.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XChangeKeyboardControl(dpy, mask, value_list)
+ register Display *dpy;
+ unsigned long mask;
+ XKeyboardControl *value_list;
+{
+ unsigned long values[8];
+ register unsigned long *value = values;
+ long nvalues;
+ register xChangeKeyboardControlReq *req;
+
+ LockDisplay(dpy);
+ GetReq(ChangeKeyboardControl, req);
+ req->mask = mask;
+
+ if (mask & KBKeyClickPercent)
+ *value++ = value_list->key_click_percent;
+
+ if (mask & KBBellPercent)
+ *value++ = value_list->bell_percent;
+
+ if (mask & KBBellPitch)
+ *value++ = value_list->bell_pitch;
+
+ if (mask & KBBellDuration)
+ *value++ = value_list->bell_duration;
+
+ if (mask & KBLed)
+ *value++ = value_list->led;
+
+ if (mask & KBLedMode)
+ *value++ = value_list->led_mode;
+
+ if (mask & KBKey)
+ *value++ = value_list->key;
+
+ if (mask & KBAutoRepeatMode)
+ *value++ = value_list->auto_repeat_mode;
+
+
+ req->length += (nvalues = value - values);
+
+ /* note: Data is a macro that uses its arguments multiple
+ times, so "nvalues" is changed in a separate assignment
+ statement */
+
+ nvalues <<= 2;
+ Data32 (dpy, (long *) values, nvalues);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+ }
diff --git a/src/ChPntCon.c b/src/ChPntCon.c
new file mode 100644
index 00000000..ce0776d9
--- /dev/null
+++ b/src/ChPntCon.c
@@ -0,0 +1,50 @@
+/* $Xorg: ChPntCon.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XChangePointerControl(dpy, do_acc, do_thresh, acc_numerator,
+ acc_denominator, threshold)
+ register Display *dpy;
+ Bool do_acc, do_thresh;
+ int acc_numerator, acc_denominator, threshold;
+
+{
+ register xChangePointerControlReq *req;
+
+ LockDisplay(dpy);
+ GetReq(ChangePointerControl, req);
+ req->doAccel = do_acc;
+ req->doThresh = do_thresh;
+ req->accelNum = acc_numerator;
+ req->accelDenum = acc_denominator;
+ req->threshold = threshold;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/ChProp.c b/src/ChProp.c
new file mode 100644
index 00000000..4cfbe96d
--- /dev/null
+++ b/src/ChProp.c
@@ -0,0 +1,107 @@
+/* $Xorg: ChProp.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+#if NeedFunctionPrototypes
+XChangeProperty (
+ register Display *dpy,
+ Window w,
+ Atom property,
+ Atom type,
+ int format, /* 8, 16, or 32 */
+ int mode, /* PropModeReplace, PropModePrepend, PropModeAppend */
+ _Xconst unsigned char *data,
+ int nelements)
+#else
+XChangeProperty (dpy, w, property, type, format, mode, data, nelements)
+ register Display *dpy;
+ Window w;
+ Atom property, type;
+ int format; /* 8, 16, or 32 */
+ int mode; /* PropModeReplace, PropModePrepend, PropModeAppend */
+ unsigned char *data;
+ int nelements;
+#endif
+ {
+ register xChangePropertyReq *req;
+ register long len;
+
+ LockDisplay(dpy);
+ GetReq (ChangeProperty, req);
+ req->window = w;
+ req->property = property;
+ req->type = type;
+ req->mode = mode;
+ if (nelements < 0) {
+ req->nUnits = 0;
+ req->format = 0; /* ask for garbage, get garbage */
+ } else {
+ req->nUnits = nelements;
+ req->format = format;
+ }
+
+ switch (req->format) {
+ case 8:
+ len = ((long)nelements + 3)>>2;
+ if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) {
+ SetReqLen(req, len, len);
+ Data (dpy, (char *)data, nelements);
+ } /* else force BadLength */
+ break;
+
+ case 16:
+ len = ((long)nelements + 1)>>1;
+ if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) {
+ SetReqLen(req, len, len);
+ len = (long)nelements << 1;
+ Data16 (dpy, (short *) data, len);
+ } /* else force BadLength */
+ break;
+
+ case 32:
+ len = nelements;
+ if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) {
+ SetReqLen(req, len, len);
+ len = (long)nelements << 2;
+ Data32 (dpy, (long *) data, len);
+ } /* else force BadLength */
+ break;
+
+ default:
+ /* BadValue will be generated */ ;
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+ }
+
+
+
+
+
diff --git a/src/ChSaveSet.c b/src/ChSaveSet.c
new file mode 100644
index 00000000..7adb08cf
--- /dev/null
+++ b/src/ChSaveSet.c
@@ -0,0 +1,58 @@
+/* $Xorg: ChSaveSet.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XChangeSaveSet(dpy, win, mode)
+register Display *dpy;
+Window win;
+int mode;
+{
+ register xChangeSaveSetReq *req;
+
+ LockDisplay(dpy);
+ GetReq(ChangeSaveSet, req);
+ req->window = win;
+ req->mode = mode;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+XAddToSaveSet(dpy, win)
+ register Display *dpy;
+ Window win;
+{
+ return XChangeSaveSet(dpy,win,SetModeInsert);
+}
+
+XRemoveFromSaveSet (dpy, win)
+ register Display *dpy;
+ Window win;
+{
+ return XChangeSaveSet(dpy,win,SetModeDelete);
+}
diff --git a/src/ChWAttrs.c b/src/ChWAttrs.c
new file mode 100644
index 00000000..2c05cf55
--- /dev/null
+++ b/src/ChWAttrs.c
@@ -0,0 +1,55 @@
+/* $Xorg: ChWAttrs.c,v 1.5 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+#define AllMaskBits (CWBackPixmap|CWBackPixel|CWBorderPixmap|\
+ CWBorderPixel|CWBitGravity|CWWinGravity|\
+ CWBackingStore|CWBackingPlanes|CWBackingPixel|\
+ CWOverrideRedirect|CWSaveUnder|CWEventMask|\
+ CWDontPropagate|CWColormap|CWCursor)
+
+XChangeWindowAttributes (dpy, w, valuemask, attributes)
+ register Display *dpy;
+ Window w;
+ unsigned long valuemask;
+ XSetWindowAttributes *attributes;
+{
+ register xChangeWindowAttributesReq *req;
+ extern void _XProcessWindowAttributes();
+
+ LockDisplay(dpy);
+ GetReq(ChangeWindowAttributes,req);
+ req->window = w;
+ valuemask &= AllMaskBits;
+ if ((req->valueMask = valuemask))
+ _XProcessWindowAttributes (dpy, req, valuemask, attributes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/ChWindow.c b/src/ChWindow.c
new file mode 100644
index 00000000..b0319aa6
--- /dev/null
+++ b/src/ChWindow.c
@@ -0,0 +1,59 @@
+/* $Xorg: ChWindow.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XResizeWindow(dpy, w, width, height)
+register Display *dpy;
+Window w;
+unsigned int width, height;
+{
+ register xConfigureWindowReq *req;
+
+ LockDisplay(dpy);
+ GetReqExtra(ConfigureWindow, 8, req); /* 2 4-byte quantities */
+
+ req->window = w;
+ req->mask = CWWidth | CWHeight;
+#ifdef MUSTCOPY
+ {
+ unsigned long lwidth = width, lheight = height;
+ dpy->bufptr -= 8;
+ Data32 (dpy, (long *) &lwidth, 4); /* order dictated by values of */
+ Data32 (dpy, (long *) &lheight, 4); /* CWWidth and CWHeight */
+ }
+#else
+ {
+ CARD32 *valuePtr = (CARD32 *) NEXTPTR(req,xConfigureWindowReq);
+ *valuePtr++ = width;
+ *valuePtr = height;
+ }
+#endif /* MUSTCOPY */
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/ChkIfEv.c b/src/ChkIfEv.c
new file mode 100644
index 00000000..24539e82
--- /dev/null
+++ b/src/ChkIfEv.c
@@ -0,0 +1,83 @@
+/* $Xorg: ChkIfEv.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1985, 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_EVENTS
+#include "Xlibint.h"
+
+/*
+ * Check existing events in queue to find if any match. If so, return.
+ * If not, flush buffer and see if any more events are readable. If one
+ * matches, return. If all else fails, tell the user no events found.
+ */
+
+Bool XCheckIfEvent (dpy, event, predicate, arg)
+ register Display *dpy;
+ Bool (*predicate)(
+#if NeedNestedPrototypes
+ Display* /* display */,
+ XEvent* /* event */,
+ char* /* arg */
+#endif
+ ); /* function to call */
+ register XEvent *event; /* XEvent to be filled in. */
+ char *arg;
+{
+ register _XQEvent *prev, *qelt;
+ unsigned long qe_serial = 0;
+ int n; /* time through count */
+
+ LockDisplay(dpy);
+ prev = NULL;
+ for (n = 3; --n >= 0;) {
+ for (qelt = prev ? prev->next : dpy->head;
+ qelt;
+ prev = qelt, qelt = qelt->next) {
+ if(qelt->qserial_num > qe_serial
+ && (*predicate)(dpy, &qelt->event, arg)) {
+ *event = qelt->event;
+ _XDeq(dpy, prev, qelt);
+ UnlockDisplay(dpy);
+ return True;
+ }
+ }
+ if (prev)
+ qe_serial = prev->qserial_num;
+ switch (n) {
+ case 2:
+ _XEventsQueued(dpy, QueuedAfterReading);
+ break;
+ case 1:
+ _XFlush(dpy);
+ break;
+ }
+ if (prev && prev->qserial_num != qe_serial)
+ /* another thread has snatched this event */
+ prev = NULL;
+ }
+ UnlockDisplay(dpy);
+ return False;
+}
diff --git a/src/ChkMaskEv.c b/src/ChkMaskEv.c
new file mode 100644
index 00000000..cc511720
--- /dev/null
+++ b/src/ChkMaskEv.c
@@ -0,0 +1,90 @@
+/* $Xorg: ChkMaskEv.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1985, 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_EVENTS
+#include "Xlibint.h"
+
+#ifdef __STDC__
+#define Const const
+#else
+#define Const /**/
+#endif
+extern long Const _Xevent_to_mask[];
+
+#define AllPointers (PointerMotionMask|PointerMotionHintMask|ButtonMotionMask)
+#define AllButtons (Button1MotionMask|Button2MotionMask|Button3MotionMask|\
+ Button4MotionMask|Button5MotionMask)
+
+/*
+ * Check existing events in queue to find if any match. If so, return.
+ * If not, flush buffer and see if any more events are readable. If one
+ * matches, return. If all else fails, tell the user no events found.
+ */
+
+Bool XCheckMaskEvent (dpy, mask, event)
+ register Display *dpy;
+ long mask; /* Selected event mask. */
+ register XEvent *event; /* XEvent to be filled in. */
+{
+ register _XQEvent *prev, *qelt;
+ unsigned long qe_serial;
+ int n; /* time through count */
+
+ LockDisplay(dpy);
+ prev = NULL;
+ for (n = 3; --n >= 0;) {
+ for (qelt = prev ? prev->next : dpy->head;
+ qelt;
+ prev = qelt, qelt = qelt->next) {
+ if ((qelt->event.type < LASTEvent) &&
+ (_Xevent_to_mask[qelt->event.type] & mask) &&
+ ((qelt->event.type != MotionNotify) ||
+ (mask & AllPointers) ||
+ (mask & AllButtons & qelt->event.xmotion.state))) {
+ *event = qelt->event;
+ _XDeq(dpy, prev, qelt);
+ UnlockDisplay(dpy);
+ return True;
+ }
+ }
+ if (prev)
+ qe_serial = prev->qserial_num;
+ switch (n) {
+ case 2:
+ _XEventsQueued(dpy, QueuedAfterReading);
+ break;
+ case 1:
+ _XFlush(dpy);
+ break;
+ }
+ if (prev && prev->qserial_num != qe_serial)
+ /* another thread has snatched this event */
+ prev = NULL;
+ }
+ UnlockDisplay(dpy);
+ return False;
+}
diff --git a/src/ChkTypEv.c b/src/ChkTypEv.c
new file mode 100644
index 00000000..dd45be0b
--- /dev/null
+++ b/src/ChkTypEv.c
@@ -0,0 +1,75 @@
+/* $Xorg: ChkTypEv.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1985, 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_EVENTS
+#include "Xlibint.h"
+
+/*
+ * Check existing events in queue to find if any match. If so, return.
+ * If not, flush buffer and see if any more events are readable. If one
+ * matches, return. If all else fails, tell the user no events found.
+ */
+
+Bool XCheckTypedEvent (dpy, type, event)
+ register Display *dpy;
+ int type; /* Selected event type. */
+ register XEvent *event; /* XEvent to be filled in. */
+{
+ register _XQEvent *prev, *qelt;
+ unsigned long qe_serial;
+ int n; /* time through count */
+
+ LockDisplay(dpy);
+ prev = NULL;
+ for (n = 3; --n >= 0;) {
+ for (qelt = prev ? prev->next : dpy->head;
+ qelt;
+ prev = qelt, qelt = qelt->next) {
+ if (qelt->event.type == type) {
+ *event = qelt->event;
+ _XDeq(dpy, prev, qelt);
+ UnlockDisplay(dpy);
+ return True;
+ }
+ }
+ if (prev)
+ qe_serial = prev->qserial_num;
+ switch (n) {
+ case 2:
+ _XEventsQueued(dpy, QueuedAfterReading);
+ break;
+ case 1:
+ _XFlush(dpy);
+ break;
+ }
+ if (prev && prev->qserial_num != qe_serial)
+ /* another thread has snatched this event */
+ prev = NULL;
+ }
+ UnlockDisplay(dpy);
+ return False;
+}
diff --git a/src/ChkTypWEv.c b/src/ChkTypWEv.c
new file mode 100644
index 00000000..09b48b5d
--- /dev/null
+++ b/src/ChkTypWEv.c
@@ -0,0 +1,77 @@
+/* $Xorg: ChkTypWEv.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1985, 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_EVENTS
+#include "Xlibint.h"
+
+/*
+ * Check existing events in queue to find if any match. If so, return.
+ * If not, flush buffer and see if any more events are readable. If one
+ * matches, return. If all else fails, tell the user no events found.
+ */
+
+Bool XCheckTypedWindowEvent (dpy, w, type, event)
+ register Display *dpy;
+ Window w; /* Selected window. */
+ int type; /* Selected event type. */
+ register XEvent *event; /* XEvent to be filled in. */
+{
+ register _XQEvent *prev, *qelt;
+ unsigned long qe_serial;
+ int n; /* time through count */
+
+ LockDisplay(dpy);
+ prev = NULL;
+ for (n = 3; --n >= 0;) {
+ for (qelt = prev ? prev->next : dpy->head;
+ qelt;
+ prev = qelt, qelt = qelt->next) {
+ if ((qelt->event.xany.window == w) &&
+ (qelt->event.type == type)) {
+ *event = qelt->event;
+ _XDeq(dpy, prev, qelt);
+ UnlockDisplay(dpy);
+ return True;
+ }
+ }
+ if (prev)
+ qe_serial = prev->qserial_num;
+ switch (n) {
+ case 2:
+ _XEventsQueued(dpy, QueuedAfterReading);
+ break;
+ case 1:
+ _XFlush(dpy);
+ break;
+ }
+ if (prev && prev->qserial_num != qe_serial)
+ /* another thread has snatched this event */
+ prev = NULL;
+ }
+ UnlockDisplay(dpy);
+ return False;
+}
diff --git a/src/ChkWinEv.c b/src/ChkWinEv.c
new file mode 100644
index 00000000..27d4c05e
--- /dev/null
+++ b/src/ChkWinEv.c
@@ -0,0 +1,91 @@
+/* $Xorg: ChkWinEv.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1985, 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_EVENTS
+#include "Xlibint.h"
+
+#ifdef __STDC__
+#define Const const
+#else
+#define Const /**/
+#endif
+extern long Const _Xevent_to_mask[];
+#define AllPointers (PointerMotionMask|PointerMotionHintMask|ButtonMotionMask)
+#define AllButtons (Button1MotionMask|Button2MotionMask|Button3MotionMask|\
+ Button4MotionMask|Button5MotionMask)
+
+/*
+ * Check existing events in queue to find if any match. If so, return.
+ * If not, flush buffer and see if any more events are readable. If one
+ * matches, return. If all else fails, tell the user no events found.
+ */
+
+Bool XCheckWindowEvent (dpy, w, mask, event)
+ register Display *dpy;
+ Window w; /* Selected window. */
+ long mask; /* Selected event mask. */
+ register XEvent *event; /* XEvent to be filled in. */
+{
+ register _XQEvent *prev, *qelt;
+ unsigned long qe_serial;
+ int n; /* time through count */
+
+ LockDisplay(dpy);
+ prev = NULL;
+ for (n = 3; --n >= 0;) {
+ for (qelt = prev ? prev->next : dpy->head;
+ qelt;
+ prev = qelt, qelt = qelt->next) {
+ if ((qelt->event.xany.window == w) &&
+ (qelt->event.type < LASTEvent) &&
+ (_Xevent_to_mask[qelt->event.type] & mask) &&
+ ((qelt->event.type != MotionNotify) ||
+ (mask & AllPointers) ||
+ (mask & AllButtons & qelt->event.xmotion.state))) {
+ *event = qelt->event;
+ _XDeq(dpy, prev, qelt);
+ UnlockDisplay(dpy);
+ return True;
+ }
+ }
+ if (prev)
+ qe_serial = prev->qserial_num;
+ switch (n) {
+ case 2:
+ _XEventsQueued(dpy, QueuedAfterReading);
+ break;
+ case 1:
+ _XFlush(dpy);
+ break;
+ }
+ if (prev && prev->qserial_num != qe_serial)
+ /* another thread has snatched this event */
+ prev = NULL;
+ }
+ UnlockDisplay(dpy);
+ return False;
+}
diff --git a/src/CirWin.c b/src/CirWin.c
new file mode 100644
index 00000000..4099900f
--- /dev/null
+++ b/src/CirWin.c
@@ -0,0 +1,45 @@
+/* $Xorg: CirWin.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XCirculateSubwindows(dpy, w, direction)
+ register Display *dpy;
+ Window w;
+ int direction;
+{
+ register xCirculateWindowReq *req;
+
+ LockDisplay(dpy);
+ GetReq(CirculateWindow, req);
+ req->window = w;
+ req->direction = direction;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/CirWinDn.c b/src/CirWinDn.c
new file mode 100644
index 00000000..c3dce796
--- /dev/null
+++ b/src/CirWinDn.c
@@ -0,0 +1,44 @@
+/* $Xorg: CirWinDn.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XCirculateSubwindowsDown(dpy,w)
+ register Display *dpy;
+ Window w;
+{
+ register xCirculateWindowReq *req;
+
+ LockDisplay(dpy);
+ GetReq(CirculateWindow, req);
+ req->window = w;
+ req->direction = LowerHighest;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/CirWinUp.c b/src/CirWinUp.c
new file mode 100644
index 00000000..65ff8645
--- /dev/null
+++ b/src/CirWinUp.c
@@ -0,0 +1,44 @@
+/* $Xorg: CirWinUp.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XCirculateSubwindowsUp(dpy, w)
+ register Display *dpy;
+ Window w;
+{
+ register xCirculateWindowReq *req;
+
+ LockDisplay(dpy);
+ GetReq(CirculateWindow, req);
+ req->window = w;
+ req->direction = RaiseLowest;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/ClDisplay.c b/src/ClDisplay.c
new file mode 100644
index 00000000..0ea2fc54
--- /dev/null
+++ b/src/ClDisplay.c
@@ -0,0 +1,70 @@
+/* $Xorg: ClDisplay.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+
+/*
+
+Copyright 1985, 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+extern void _XFreeDisplayStructure();
+
+/*
+ * XCloseDisplay - XSync the connection to the X Server, close the connection,
+ * and free all associated storage. Extension close procs should only free
+ * memory and must be careful about the types of requests they generate.
+ */
+
+XCloseDisplay (dpy)
+ register Display *dpy;
+{
+ register _XExtension *ext;
+ register int i;
+
+ if (!(dpy->flags & XlibDisplayClosing))
+ {
+ dpy->flags |= XlibDisplayClosing;
+ for (i = 0; i < dpy->nscreens; i++) {
+ register Screen *sp = &dpy->screens[i];
+ XFreeGC (dpy, sp->default_gc);
+ }
+ if (dpy->cursor_font != None) {
+ XUnloadFont (dpy, dpy->cursor_font);
+ }
+ XSync(dpy, 1); /* throw away pending events, catch errors */
+ /* call out to any extensions interested */
+ for (ext = dpy->ext_procs; ext; ext = ext->next) {
+ if (ext->close_display)
+ (*ext->close_display)(dpy, &ext->codes);
+ }
+ /* if the closes generated more protocol, sync them up */
+ if (dpy->request != dpy->last_request_read)
+ XSync(dpy, 1);
+ }
+ _XDisconnectDisplay(dpy->trans_conn);
+ _XFreeDisplayStructure (dpy);
+ return 0;
+}
diff --git a/src/Clear.c b/src/Clear.c
new file mode 100644
index 00000000..54fde13e
--- /dev/null
+++ b/src/Clear.c
@@ -0,0 +1,46 @@
+/* $Xorg: Clear.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XClearWindow(dpy, w)
+ register Display *dpy;
+ Window w;
+{
+ register xClearAreaReq *req;
+
+ LockDisplay(dpy);
+ GetReq(ClearArea, req);
+ req->window = w;
+ req->x = req->y = req->width = req->height = 0;
+ /* these values mean "clear the entire window" */
+ req->exposures = xFalse;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/ClearArea.c b/src/ClearArea.c
new file mode 100644
index 00000000..4028ae44
--- /dev/null
+++ b/src/ClearArea.c
@@ -0,0 +1,51 @@
+/* $Xorg: ClearArea.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XClearArea (dpy, w, x, y, width, height, exposures)
+ register Display *dpy;
+ Window w;
+ int x, y;
+ unsigned int width, height;
+ Bool exposures;
+{
+ register xClearAreaReq *req;
+
+ LockDisplay(dpy);
+ GetReq(ClearArea, req);
+ req->window = w;
+ req->x = x;
+ req->y = y;
+ req->width = width;
+ req->height = height;
+ req->exposures = exposures;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/ConfWind.c b/src/ConfWind.c
new file mode 100644
index 00000000..f4bb4239
--- /dev/null
+++ b/src/ConfWind.c
@@ -0,0 +1,66 @@
+/* $Xorg: ConfWind.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XMoveResizeWindow(dpy, w, x, y, width, height)
+register Display *dpy;
+Window w;
+int x, y;
+unsigned int width, height;
+{
+ register xConfigureWindowReq *req;
+
+ LockDisplay(dpy);
+ GetReqExtra(ConfigureWindow, 16, req);
+ req->window = w;
+ req->mask = CWX | CWY | CWWidth | CWHeight;
+#ifdef MUSTCOPY
+ {
+ long lx = x, ly = y;
+ unsigned long lwidth = width, lheight = height;
+
+ dpy->bufptr -= 16;
+ Data32 (dpy, (long *) &lx, 4); /* order must match values of */
+ Data32 (dpy, (long *) &ly, 4); /* CWX, CWY, CWWidth, and CWHeight */
+ Data32 (dpy, (long *) &lwidth, 4);
+ Data32 (dpy, (long *) &lheight, 4);
+ }
+#else
+ {
+ register CARD32 *valuePtr =
+ (CARD32 *) NEXTPTR(req,xConfigureWindowReq);
+ *valuePtr++ = x;
+ *valuePtr++ = y;
+ *valuePtr++ = width;
+ *valuePtr = height;
+ }
+#endif /* MUSTCOPY */
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/ConnDis.c b/src/ConnDis.c
new file mode 100644
index 00000000..9ee55118
--- /dev/null
+++ b/src/ConnDis.c
@@ -0,0 +1,1157 @@
+/* $Xorg: ConnDis.c,v 1.8 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * This file contains operating system dependencies.
+ */
+
+#define NEED_EVENTS
+
+#include <X11/Xlibint.h>
+#include <X11/Xtrans.h>
+#include <X11/Xauth.h>
+#include <stdio.h>
+#include <ctype.h>
+
+#ifndef WIN32
+#include <sys/socket.h>
+#endif
+
+#ifndef X_CONNECTION_RETRIES /* number retries on ECONNREFUSED */
+#define X_CONNECTION_RETRIES 5
+#endif
+
+#ifdef LOCALCONN
+#include <sys/utsname.h>
+#endif
+
+static void GetAuthorization();
+
+static char *copystring (src, len)
+ char *src;
+ int len;
+{
+ char *dst = Xmalloc (len + 1);
+
+ if (dst) {
+ strncpy (dst, src, len);
+ dst[len] = '\0';
+ }
+
+ return dst;
+}
+
+
+/*
+ * Attempts to connect to server, given display name. Returns file descriptor
+ * (network socket) or -1 if connection fails. Display names may be of the
+ * following format:
+ *
+ * [protocol/] [hostname] : [:] displaynumber [.screennumber]
+ *
+ * The second colon indicates a DECnet style name. No hostname is interpretted
+ * as the most efficient local connection to a server on the same machine.
+ * This is usually:
+ *
+ * o shared memory
+ * o local stream
+ * o UNIX domain socket
+ * o TCP to local host
+ *
+ * This function will eventually call the X Transport Interface functions
+ * which expects the hostname in the format:
+ *
+ * [protocol/] [hostname] : [:] displaynumber
+ *
+ */
+XtransConnInfo
+_X11TransConnectDisplay (display_name, fullnamep, dpynump, screenp,
+ auth_namep, auth_namelenp, auth_datap, auth_datalenp)
+ char *display_name;
+ char **fullnamep; /* RETURN */
+ int *dpynump; /* RETURN */
+ int *screenp; /* RETURN */
+ char **auth_namep; /* RETURN */
+ int *auth_namelenp; /* RETURN */
+ char **auth_datap; /* RETURN */
+ int *auth_datalenp; /* RETURN */
+{
+ int family;
+ int saddrlen;
+ Xtransaddr *saddr;
+ char *lastp, *lastc, *p; /* char pointers */
+ char *pprotocol = NULL; /* start of protocol name */
+ char *phostname = NULL; /* start of host of display */
+ char *pdpynum = NULL; /* start of dpynum of display */
+ char *pscrnum = NULL; /* start of screen of display */
+ Bool dnet = False; /* if true, then DECnet format */
+ int idisplay; /* required display number */
+ int iscreen = 0; /* optional screen number */
+ int (*connfunc)(); /* method to create connection */
+ int len, hostlen; /* length tmp variable */
+ int retry; /* retry counter */
+ char addrbuf[128]; /* final address passed to
+ X Transport Interface */
+ char* address = addrbuf;
+ XtransConnInfo trans_conn = NULL; /* transport connection object */
+ int connect_stat;
+#ifdef LOCALCONN
+ struct utsname sys;
+#ifdef TCPCONN
+ char *tcphostname = NULL; /* A place to save hostname pointer */
+#endif
+#endif
+
+ p = display_name;
+
+ saddrlen = 0; /* set so that we can clear later */
+ saddr = NULL;
+
+ /*
+ * Step 0, find the protocol. This is delimited by the optional
+ * slash ('/').
+ */
+ for (lastp = p; *p && *p != ':' && *p != '/'; p++) ;
+ if (!*p) return NULL; /* must have a colon */
+
+ if (p != lastp && *p != ':') { /* protocol given? */
+ pprotocol = copystring (lastp, p - lastp);
+ if (!pprotocol) goto bad; /* no memory */
+ p++; /* skip the '/' */
+ } else
+ p = display_name; /* reset the pointer in
+ case no protocol was given */
+
+ /*
+ * Step 1, find the hostname. This is delimited by either one colon,
+ * or two colons in the case of DECnet (DECnet Phase V allows a single
+ * colon in the hostname).
+ */
+
+ lastp = p;
+ lastc = NULL;
+ for (; *p; p++)
+ if (*p == ':')
+ lastc = p;
+
+ if (!lastc) return NULL; /* must have a colon */
+
+ if ((lastp != lastc) && (*(lastc - 1) == ':')) {
+ /* DECnet display specified */
+
+#ifndef DNETCONN
+ goto bad;
+#else
+ dnet = True;
+ /* override the protocol specified */
+ if (pprotocol)
+ Xfree (pprotocol);
+ pprotocol = copystring ("dnet", 4);
+ hostlen = lastc - 1 - lastp;
+#endif
+ }
+ else
+ hostlen = lastc - lastp;
+
+ if (hostlen > 0) { /* hostname given? */
+ phostname = copystring (lastp, hostlen);
+ if (!phostname) goto bad; /* no memory */
+ }
+
+ p = lastc;
+
+#ifdef LOCALCONN
+ /* check if phostname == localnodename AND protocol not specified */
+ if (!pprotocol && phostname && uname(&sys) >= 0 &&
+ !strncmp(phostname, sys.nodename,
+ (strlen(sys.nodename) < strlen(phostname) ?
+ strlen(phostname) : strlen(sys.nodename))))
+ {
+#ifdef TCPCONN
+ /*
+ * We'll first attempt to connect using the local transport. If
+ * this fails (which is the case if sshd X protocol forwarding is
+ * being used), retry using tcp and this hostname.
+ */
+ tcphostname = copystring(phostname, strlen(phostname));
+#endif
+ Xfree (phostname);
+ phostname = copystring ("unix", 4);
+ }
+#endif
+
+
+ /*
+ * Step 2, find the display number. This field is required and is
+ * delimited either by a nul or a period, depending on whether or not
+ * a screen number is present.
+ */
+
+ for (lastp = ++p; *p && isascii(*p) && isdigit(*p); p++) ;
+ if ((p == lastp) || /* required field */
+ (*p != '\0' && *p != '.') || /* invalid non-digit terminator */
+ !(pdpynum = copystring (lastp, p - lastp))) /* no memory */
+ goto bad;
+ idisplay = atoi (pdpynum);
+
+
+ /*
+ * Step 3, find the screen number. This field is optional. It is
+ * present only if the display number was followed by a period (which
+ * we've already verified is the only non-nul character).
+ */
+
+ if (*p) {
+ for (lastp = ++p; *p && isascii(*p) && isdigit (*p); p++) ;
+ if (p != lastp) {
+ if (*p || /* non-digits */
+ !(pscrnum = copystring (lastp, p - lastp))) /* no memory */
+ goto bad;
+ iscreen = atoi (lastp);
+ }
+ }
+
+ /*
+ * At this point, we know the following information:
+ *
+ * pprotocol protocol string or NULL
+ * phostname hostname string or NULL
+ * idisplay display number
+ * iscreen screen number
+ * dnet DECnet boolean
+ *
+ * We can now decide which transport to use based on the ConnectionFlags
+ * build parameter the hostname string. If phostname is NULL or equals
+ * the string "local", then choose the best transport. If phostname
+ * is "unix", then choose BSD UNIX domain sockets (if configured).
+ */
+
+#if defined(TCPCONN) || defined(UNIXCONN) || defined(LOCALCONN)
+ if (!pprotocol) {
+ if (!phostname)
+#if defined(UNIXCONN) || defined(LOCALCONN)
+ pprotocol = copystring ("local", 5);
+ else
+#endif
+ pprotocol = copystring ("tcp", 3);
+ }
+#endif
+
+#if defined(UNIXCONN) || defined(LOCALCONN)
+ /*
+ * Now that the defaults have been established, see if we have any
+ * special names that we have to override:
+ *
+ * :N => if UNIXCONN then unix-domain-socket
+ * ::N => if UNIXCONN then unix-domain-socket
+ * unix:N => if UNIXCONN then unix-domain-socket
+ *
+ * Note that if UNIXCONN isn't defined, then we can use the default
+ * transport connection function set above.
+ */
+
+ if (!phostname) {
+#ifdef apollo
+ ; /* Unix domain sockets are *really* bad on apollos */
+#else
+ if( pprotocol ) Xfree(pprotocol);
+ pprotocol = copystring ("local", 5);
+#endif
+ }
+ else if (strcmp (phostname, "unix") == 0) {
+ if( pprotocol ) Xfree(pprotocol);
+ pprotocol = copystring ("local", 5);
+ }
+#endif
+
+ connect:
+ /*
+ * This seems kind of backwards, but we need to put the protocol,
+ * host, and port back together to pass to _X11TransOpenCOTSClient().
+ */
+
+ {
+ int olen = 3 + (pprotocol ? strlen(pprotocol) : 0) +
+ (phostname ? strlen(phostname) : 0) +
+ (pdpynum ? strlen(pdpynum) : 0);
+ if (olen > sizeof addrbuf) address = Xmalloc (olen);
+ }
+
+ sprintf(address,"%s/%s:%s",
+ pprotocol ? pprotocol : "",
+ phostname ? phostname : "",
+ pdpynum );
+
+ /*
+ * Make the connection, also need to get the auth address info for
+ * the connection. Do retries in case server host has hit its
+ * backlog (which, unfortunately, isn't distinguishable from there not
+ * being a server listening at all, which is why we have to not retry
+ * too many times).
+ */
+ for(retry=X_CONNECTION_RETRIES; retry>=0; retry-- )
+ {
+ if ( (trans_conn = _X11TransOpenCOTSClient(address)) == NULL )
+ {
+ break;
+ }
+ if ((connect_stat = _X11TransConnect(trans_conn,address)) < 0 )
+ {
+ _X11TransClose(trans_conn);
+ trans_conn = NULL;
+
+ if (connect_stat == TRANS_TRY_CONNECT_AGAIN)
+ {
+ sleep(1);
+ continue;
+ }
+ else
+ break;
+ }
+
+ _X11TransGetPeerAddr(trans_conn, &family, &saddrlen, &saddr);
+
+ /*
+ * The family is given in a socket format (ie AF_INET). This
+ * will convert it to the format used by the authorization and
+ * X protocol (ie FamilyInternet).
+ */
+
+ if( _X11TransConvertAddress(&family, &saddrlen, &saddr) < 0 )
+ {
+ _X11TransClose(trans_conn);
+ trans_conn = NULL;
+ sleep(1);
+ if (saddr)
+ {
+ free ((char *) saddr);
+ saddr = NULL;
+ }
+ continue;
+ }
+
+ break;
+ }
+
+ if (address != addrbuf) Xfree (address);
+
+ if( trans_conn == NULL )
+ goto bad;
+
+ /*
+ * Set close-on-exec so that programs that fork() doesn't get confused.
+ */
+
+ _X11TransSetOption(trans_conn,TRANS_CLOSEONEXEC,1);
+
+ /*
+ * Build the expanded display name:
+ *
+ * [host] : [:] dpy . scr \0
+ */
+ len = ((phostname ? strlen(phostname) : 0) + 1 + (dnet ? 1 : 0) +
+ strlen(pdpynum) + 1 + (pscrnum ? strlen(pscrnum) : 1) + 1);
+ *fullnamep = (char *) Xmalloc (len);
+ if (!*fullnamep) goto bad;
+
+ sprintf (*fullnamep, "%s%s%d.%d",
+ (phostname ? phostname : ""),
+ (dnet ? "::" : ":"),
+ idisplay, iscreen);
+
+ *dpynump = idisplay;
+ *screenp = iscreen;
+ if (pprotocol) Xfree (pprotocol);
+ if (phostname) Xfree (phostname);
+ if (pdpynum) Xfree (pdpynum);
+ if (pscrnum) Xfree (pscrnum);
+
+ GetAuthorization(trans_conn, family, (char *) saddr, saddrlen, idisplay,
+ auth_namep, auth_namelenp, auth_datap, auth_datalenp);
+ return trans_conn;
+
+
+ /*
+ * error return; make sure everything is cleaned up.
+ */
+ bad:
+ if (trans_conn) (void)_X11TransClose(trans_conn);
+ if (saddr) free ((char *) saddr);
+ if (pprotocol) Xfree (pprotocol);
+ if (phostname) Xfree (phostname);
+
+#if defined(LOCALCONN) && defined(TCPCONN)
+ if (tcphostname) {
+ pprotocol = copystring("tcp", 3);
+ phostname = tcphostname;
+ tcphostname = NULL;
+ goto connect;
+ }
+#endif
+
+ if (pdpynum) Xfree (pdpynum);
+ if (pscrnum) Xfree (pscrnum);
+ return NULL;
+
+}
+
+/*
+ * This is gross, but we need it for compatiblity.
+ * The test suite relies on the following interface.
+ *
+ */
+
+int _XConnectDisplay (display_name, fullnamep, dpynump, screenp,
+ auth_namep, auth_namelenp, auth_datap, auth_datalenp)
+ char *display_name;
+ char **fullnamep; /* RETURN */
+ int *dpynump; /* RETURN */
+ int *screenp; /* RETURN */
+ char **auth_namep; /* RETURN */
+ int *auth_namelenp; /* RETURN */
+ char **auth_datap; /* RETURN */
+ int *auth_datalenp; /* RETURN */
+{
+ XtransConnInfo trans_conn;
+
+ trans_conn = _X11TransConnectDisplay (
+ display_name, fullnamep, dpynump, screenp,
+ auth_namep, auth_namelenp, auth_datap, auth_datalenp);
+
+ if (trans_conn)
+ {
+ int fd = _X11TransGetConnectionNumber (trans_conn);
+ _X11TransFreeConnInfo (trans_conn);
+ return (fd);
+ }
+ else
+ return (-1);
+}
+
+
+/*****************************************************************************
+ * *
+ * Connection Utility Routines *
+ * *
+ *****************************************************************************/
+
+/*
+ * Disconnect from server.
+ */
+
+int _XDisconnectDisplay (trans_conn)
+
+XtransConnInfo trans_conn;
+
+{
+ _X11TransDisconnect(trans_conn);
+ _X11TransClose(trans_conn);
+ return 0;
+}
+
+
+
+static int padlength[4] = {0, 3, 2, 1}; /* make sure auth is multiple of 4 */
+
+Bool
+_XSendClientPrefix (dpy, client, auth_proto, auth_string, prefix)
+ Display *dpy;
+ xConnClientPrefix *client; /* contains count for auth_* */
+ char *auth_proto, *auth_string; /* NOT null-terminated */
+ xConnSetupPrefix *prefix; /* prefix information */
+{
+ int auth_length = client->nbytesAuthProto;
+ int auth_strlen = client->nbytesAuthString;
+ char padbuf[3]; /* for padding to 4x bytes */
+ int pad;
+ struct iovec iovarray[5], *iov = iovarray;
+ int niov = 0;
+ int len = 0;
+
+#define add_to_iov(b,l) \
+ { iov->iov_base = (b); iov->iov_len = (l); iov++, niov++; len += (l); }
+
+ add_to_iov ((caddr_t) client, SIZEOF(xConnClientPrefix));
+
+ /*
+ * write authorization protocol name and data
+ */
+ if (auth_length > 0) {
+ add_to_iov (auth_proto, auth_length);
+ pad = padlength [auth_length & 3];
+ if (pad) add_to_iov (padbuf, pad);
+ }
+ if (auth_strlen > 0) {
+ add_to_iov (auth_string, auth_strlen);
+ pad = padlength [auth_strlen & 3];
+ if (pad) add_to_iov (padbuf, pad);
+ }
+
+#undef add_to_iov
+
+ len -= _X11TransWritev (dpy->trans_conn, iovarray, niov);
+
+ /*
+ * Set the connection non-blocking since we use select() to block.
+ */
+
+ _X11TransSetOption(dpy->trans_conn, TRANS_NONBLOCKING, 1);
+
+ if (len != 0)
+ return -1;
+
+#ifdef K5AUTH
+ if (auth_length == 14 &&
+ !strncmp(auth_proto, "MIT-KERBEROS-5", 14))
+ {
+ return k5_clientauth(dpy, prefix);
+ } else
+#endif
+ return 0;
+}
+
+
+#ifdef STREAMSCONN
+#ifdef SVR4
+#include <tiuser.h>
+#else
+#undef HASXDMAUTH
+#endif
+#endif
+
+#ifdef SECURE_RPC
+#include <rpc/rpc.h>
+#ifdef ultrix
+#include <time.h>
+#include <rpc/auth_des.h>
+#endif
+#endif
+
+#ifdef HASXDMAUTH
+#ifdef X_NOT_STDC_ENV
+#define Time_t long
+extern Time_t time ();
+#else
+#include <time.h>
+#define Time_t time_t
+#endif
+#endif
+
+/*
+ * First, a routine for setting authorization data
+ */
+static int xauth_namelen = 0;
+static char *xauth_name = NULL; /* NULL means use default mechanism */
+static int xauth_datalen = 0;
+static char *xauth_data = NULL; /* NULL means get default data */
+
+/*
+ * This is a list of the authorization names which Xlib currently supports.
+ * Xau will choose the file entry which matches the earliest entry in this
+ * array, allowing us to prioritize these in terms of the most secure first
+ */
+
+static char *default_xauth_names[] = {
+#ifdef K5AUTH
+ "MIT-KERBEROS-5",
+#endif
+#ifdef SECURE_RPC
+ "SUN-DES-1",
+#endif
+#ifdef HASXDMAUTH
+ "XDM-AUTHORIZATION-1",
+#endif
+ "MIT-MAGIC-COOKIE-1"
+};
+
+static int default_xauth_lengths[] = {
+#ifdef K5AUTH
+ 14, /* strlen ("MIT-KERBEROS-5") */
+#endif
+#ifdef SECURE_RPC
+ 9, /* strlen ("SUN-DES-1") */
+#endif
+#ifdef HASXDMAUTH
+ 19, /* strlen ("XDM-AUTHORIZATION-1") */
+#endif
+ 18 /* strlen ("MIT-MAGIC-COOKIE-1") */
+};
+
+#define NUM_DEFAULT_AUTH (sizeof (default_xauth_names) / sizeof (default_xauth_names[0]))
+
+static char **xauth_names = default_xauth_names;
+static int *xauth_lengths = default_xauth_lengths;
+
+static int xauth_names_length = NUM_DEFAULT_AUTH;
+
+void XSetAuthorization (name, namelen, data, datalen)
+ int namelen, datalen; /* lengths of name and data */
+ char *name, *data; /* NULL or arbitrary array of bytes */
+{
+ char *tmpname, *tmpdata;
+
+ _XLockMutex(_Xglobal_lock);
+ if (xauth_name) Xfree (xauth_name); /* free any existing data */
+ if (xauth_data) Xfree (xauth_data);
+
+ xauth_name = xauth_data = NULL; /* mark it no longer valid */
+ xauth_namelen = xauth_datalen = 0;
+ _XUnlockMutex(_Xglobal_lock);
+
+ if (namelen < 0) namelen = 0; /* check for bogus inputs */
+ if (datalen < 0) datalen = 0; /* maybe should return? */
+
+ if (namelen > 0) { /* try to allocate space */
+ tmpname = Xmalloc ((unsigned) namelen);
+ if (!tmpname) return;
+ memcpy (tmpname, name, namelen);
+ } else {
+ tmpname = NULL;
+ }
+
+ if (datalen > 0) {
+ tmpdata = Xmalloc ((unsigned) datalen);
+ if (!tmpdata) {
+ if (tmpname) (void) Xfree (tmpname);
+ return;
+ }
+ memcpy (tmpdata, data, datalen);
+ } else {
+ tmpdata = NULL;
+ }
+
+ _XLockMutex(_Xglobal_lock);
+ xauth_name = tmpname; /* and store the suckers */
+ xauth_namelen = namelen;
+ if (tmpname)
+ {
+ xauth_names = &xauth_name;
+ xauth_lengths = &xauth_namelen;
+ xauth_names_length = 1;
+ }
+ else
+ {
+ xauth_names = default_xauth_names;
+ xauth_lengths = default_xauth_lengths;
+ xauth_names_length = NUM_DEFAULT_AUTH;
+ }
+ xauth_data = tmpdata;
+ xauth_datalen = datalen;
+ _XUnlockMutex(_Xglobal_lock);
+ return;
+}
+
+#ifdef SECURE_RPC
+/*
+ * Create a credential that we can send to the X server.
+ */
+static int
+auth_ezencode(servername, window, cred_out, len)
+ char *servername;
+ int window;
+ char *cred_out;
+ int *len;
+{
+ AUTH *a;
+ XDR xdr;
+
+ a = (AUTH *)authdes_create(servername, window, NULL, NULL);
+ if (a == (AUTH *)NULL) {
+ perror("auth_create");
+ return 0;
+ }
+ xdrmem_create(&xdr, cred_out, *len, XDR_ENCODE);
+ if (AUTH_MARSHALL(a, &xdr) == FALSE) {
+ perror("auth_marshall");
+ AUTH_DESTROY(a);
+ return 0;
+ }
+ *len = xdr_getpos(&xdr);
+ AUTH_DESTROY(a);
+ return 1;
+}
+#endif
+
+#ifdef K5AUTH
+#include <com_err.h>
+
+extern krb5_flags krb5_kdc_default_options;
+
+/*
+ * k5_clientauth
+ *
+ * Returns non-zero if the setup prefix has been read,
+ * so we can tell XOpenDisplay to not bother looking for it by
+ * itself.
+ */
+static int k5_clientauth(dpy, sprefix)
+ Display *dpy;
+ xConnSetupPrefix *sprefix;
+{
+ krb5_error_code retval;
+ xReq prefix;
+ char *buf;
+ CARD16 plen, tlen;
+ krb5_data kbuf;
+ krb5_ccache cc;
+ krb5_creds creds;
+ krb5_principal cprinc, sprinc;
+ krb5_ap_rep_enc_part *repl;
+
+ krb5_init_ets();
+ /*
+ * stage 0: get encoded principal and tgt from server
+ */
+ _XRead(dpy, (char *)&prefix, sz_xReq);
+ if (prefix.reqType != 2 && prefix.reqType != 3)
+ /* not an auth packet... so deal */
+ if (prefix.reqType == 0 || prefix.reqType == 1)
+ {
+ memcpy((char *)sprefix, (char *)&prefix, sz_xReq);
+ _XRead(dpy, (char *)sprefix + sz_xReq,
+ sz_xConnSetupPrefix - sz_xReq); /* ewww... gross */
+ return 1;
+ }
+ else
+ {
+ fprintf(stderr,
+ "Xlib: Krb5 stage 0: got illegal connection setup success code %d\n",
+ prefix.reqType);
+ return -1;
+ }
+ if (prefix.data != 0)
+ {
+ fprintf(stderr, "Xlib: got out of sequence (%d) packet in Krb5 auth\n",
+ prefix.data);
+ return -1;
+ }
+ buf = (char *)malloc((prefix.length << 2) - sz_xReq);
+ if (buf == NULL) /* malloc failed. Run away! */
+ {
+ fprintf(stderr, "Xlib: malloc bombed in Krb5 auth\n");
+ return -1;
+ }
+ tlen = (prefix.length << 2) - sz_xReq;
+ _XRead(dpy, buf, tlen);
+ if (prefix.reqType == 2 && tlen < 6)
+ {
+ fprintf(stderr, "Xlib: Krb5 stage 0 reply from server too short\n");
+ free(buf);
+ return -1;
+ }
+ if (prefix.reqType == 2)
+ {
+ plen = *(CARD16 *)buf;
+ kbuf.data = buf + 2;
+ kbuf.length = (plen > tlen) ? tlen : plen;
+ }
+ else
+ {
+ kbuf.data = buf;
+ kbuf.length = tlen;
+ }
+ if (XauKrb5Decode(kbuf, &sprinc))
+ {
+ free(buf);
+ fprintf(stderr, "Xlib: XauKrb5Decode bombed\n");
+ return -1;
+ }
+ if (prefix.reqType == 3) /* do some special stuff here */
+ {
+ char *sname, *hostname = NULL;
+
+ sname = (char *)malloc(krb5_princ_component(sprinc, 0)->length + 1);
+ if (sname == NULL)
+ {
+ free(buf);
+ krb5_free_principal(sprinc);
+ fprintf(stderr, "Xlib: malloc bombed in Krb5 auth\n");
+ return -1;
+ }
+ memcpy(sname, krb5_princ_component(sprinc, 0)->data,
+ krb5_princ_component(sprinc, 0)->length);
+ sname[krb5_princ_component(sprinc, 0)->length] = '\0';
+ krb5_free_principal(sprinc);
+ if (dpy->display_name[0] != ':') /* hunt for a hostname */
+ {
+ char *t;
+
+ if ((hostname = (char *)malloc(strlen(dpy->display_name)))
+ == NULL)
+ {
+ free(buf);
+ free(sname);
+ fprintf(stderr, "Xlib: malloc bombed in Krb5 auth\n");
+ return -1;
+ }
+ strcpy(hostname, dpy->display_name);
+ t = strchr(hostname, ':');
+ if (t == NULL)
+ {
+ free(buf);
+ free(sname);
+ free(hostname);
+ fprintf(stderr,
+ "Xlib: shouldn't get here! malformed display name.");
+ return -1;
+ }
+ if ((t - hostname + 1 < strlen(hostname)) && t[1] == ':')
+ t++;
+ *t = '\0'; /* truncate the dpy number out */
+ }
+ retval = krb5_sname_to_principal(hostname, sname,
+ KRB5_NT_SRV_HST, &sprinc);
+ free(sname);
+ if (hostname)
+ free(hostname);
+ if (retval)
+ {
+ free(buf);
+ fprintf(stderr, "Xlib: krb5_sname_to_principal failed: %s\n",
+ error_message(retval));
+ return -1;
+ }
+ }
+ if (retval = krb5_cc_default(&cc))
+ {
+ free(buf);
+ krb5_free_principal(sprinc);
+ fprintf(stderr, "Xlib: krb5_cc_default failed: %s\n",
+ error_message(retval));
+ return -1;
+ }
+ if (retval = krb5_cc_get_principal(cc, &cprinc))
+ {
+ free(buf);
+ krb5_free_principal(sprinc);
+ fprintf(stderr, "Xlib: cannot get Kerberos principal from \"%s\": %s\n",
+ krb5_cc_default_name(), error_message(retval));
+ return -1;
+ }
+ bzero((char *)&creds, sizeof(creds));
+ creds.server = sprinc;
+ creds.client = cprinc;
+ if (prefix.reqType == 2)
+ {
+ creds.second_ticket.length = tlen - plen - 2;
+ creds.second_ticket.data = buf + 2 + plen;
+ retval = krb5_get_credentials(KRB5_GC_USER_USER |
+ krb5_kdc_default_options,
+ cc, &creds);
+ }
+ else
+ retval = krb5_get_credentials(krb5_kdc_default_options,
+ cc, &creds);
+ if (retval)
+ {
+ free(buf);
+ krb5_free_cred_contents(&creds);
+ fprintf(stderr, "Xlib: cannot get Kerberos credentials: %s\n",
+ error_message(retval));
+ return -1;
+ }
+ /*
+ * now format the ap_req to send to the server
+ */
+ if (prefix.reqType == 2)
+ retval = krb5_mk_req_extended(AP_OPTS_USE_SESSION_KEY |
+ AP_OPTS_MUTUAL_REQUIRED, NULL,
+ 0, 0, NULL, cc,
+ &creds, NULL, &kbuf);
+ else
+ retval = krb5_mk_req_extended(AP_OPTS_MUTUAL_REQUIRED, NULL,
+ 0, 0, NULL, cc, &creds, NULL,
+ &kbuf);
+ free(buf);
+ if (retval) /* Some manner of Kerberos lossage */
+ {
+ krb5_free_cred_contents(&creds);
+ fprintf(stderr, "Xlib: krb5_mk_req_extended failed: %s\n",
+ error_message(retval));
+ return -1;
+ }
+ prefix.reqType = 1;
+ prefix.data = 0;
+ prefix.length = (kbuf.length + sz_xReq + 3) >> 2;
+ /*
+ * stage 1: send ap_req to server
+ */
+ _XSend(dpy, (char *)&prefix, sz_xReq);
+ _XSend(dpy, (char *)kbuf.data, kbuf.length);
+ free(kbuf.data);
+ /*
+ * stage 2: get ap_rep from server to mutually authenticate
+ */
+ _XRead(dpy, (char *)&prefix, sz_xReq);
+ if (prefix.reqType != 2)
+ if (prefix.reqType == 0 || prefix.reqType == 1)
+ {
+ memcpy((char *)sprefix, (char *)&prefix, sz_xReq);
+ _XRead(dpy, (char *)sprefix + sz_xReq,
+ sz_xConnSetupPrefix - sz_xReq);
+ return 1;
+ }
+ else
+ {
+ fprintf(stderr,
+ "Xlib: Krb5 stage 2: got illegal connection setup success code %d\n",
+ prefix.reqType);
+ return -1;
+ }
+ if (prefix.data != 2)
+ return -1;
+ kbuf.length = (prefix.length << 2) - sz_xReq;
+ kbuf.data = (char *)malloc(kbuf.length);
+ if (kbuf.data == NULL)
+ {
+ fprintf(stderr, "Xlib: malloc bombed in Krb5 auth\n");
+ return -1;
+ }
+ _XRead(dpy, (char *)kbuf.data, kbuf.length);
+ retval = krb5_rd_rep(&kbuf, &creds.keyblock, &repl);
+ if (retval)
+ {
+ free(kbuf.data);
+ fprintf(stderr, "Xlib: krb5_rd_rep failed: %s\n",
+ error_message(retval));
+ return -1;
+ }
+ free(kbuf.data);
+ /*
+ * stage 3: send a short ack to the server and return
+ */
+ prefix.reqType = 3;
+ prefix.data = 0;
+ prefix.length = sz_xReq >> 2;
+ _XSend(dpy, (char *)&prefix, sz_xReq);
+ return 0;
+}
+#endif /* K5AUTH */
+
+static void
+GetAuthorization(trans_conn, family, saddr, saddrlen, idisplay,
+ auth_namep, auth_namelenp, auth_datap, auth_datalenp)
+ XtransConnInfo trans_conn;
+ int family;
+ int saddrlen;
+ int idisplay;
+ char *saddr;
+ char **auth_namep; /* RETURN */
+ int *auth_namelenp; /* RETURN */
+ char **auth_datap; /* RETURN */
+ int *auth_datalenp; /* RETURN */
+{
+#ifdef SECURE_RPC
+ char rpc_cred[MAX_AUTH_BYTES];
+#endif
+#ifdef HASXDMAUTH
+ char xdmcp_data[192/8];
+#endif
+ char *auth_name;
+ int auth_namelen;
+ char *auth_data;
+ int auth_datalen;
+ Xauth *authptr = NULL;
+
+/*
+ * Look up the authorization protocol name and data if necessary.
+ */
+ if (xauth_name && xauth_data) {
+ auth_namelen = xauth_namelen;
+ auth_name = xauth_name;
+ auth_datalen = xauth_datalen;
+ auth_data = xauth_data;
+ } else {
+ char dpynumbuf[40]; /* big enough to hold 2^64 and more */
+ (void) sprintf (dpynumbuf, "%d", idisplay);
+
+ authptr = XauGetBestAuthByAddr ((unsigned short) family,
+ (unsigned short) saddrlen,
+ saddr,
+ (unsigned short) strlen (dpynumbuf),
+ dpynumbuf,
+ xauth_names_length,
+ xauth_names,
+ xauth_lengths);
+ if (authptr) {
+ auth_namelen = authptr->name_length;
+ auth_name = (char *)authptr->name;
+ auth_datalen = authptr->data_length;
+ auth_data = (char *)authptr->data;
+ } else {
+ auth_namelen = 0;
+ auth_name = NULL;
+ auth_datalen = 0;
+ auth_data = NULL;
+ }
+ }
+#ifdef HASXDMAUTH
+ /*
+ * build XDM-AUTHORIZATION-1 data
+ */
+ if (auth_namelen == 19 && !strncmp (auth_name, "XDM-AUTHORIZATION-1", 19))
+ {
+ int i, j;
+ Time_t now;
+ int family, addrlen;
+ Xtransaddr *addr = NULL;
+
+ for (j = 0; j < 8; j++)
+ xdmcp_data[j] = auth_data[j];
+
+ _X11TransGetMyAddr(trans_conn, &family, &addrlen, &addr);
+
+ switch( family )
+ {
+#ifdef AF_INET
+ case AF_INET:
+ {
+ /*
+ * addr will contain a sockaddr_in with all
+ * of the members already in network byte order.
+ */
+
+ for(i=4; i<8; i++) /* do sin_addr */
+ xdmcp_data[j++] = ((char *)addr)[i];
+ for(i=2; i<4; i++) /* do sin_port */
+ xdmcp_data[j++] = ((char *)addr)[i];
+ break;
+ }
+#endif /* AF_INET */
+#ifdef AF_UNIX
+ case AF_UNIX:
+ {
+ /*
+ * We don't use the sockaddr_un for this encoding.
+ * Instead, we create a sockaddr_in filled with
+ * a decreasing counter for the address, and the
+ * pid for the port.
+ */
+
+ static unsigned long unix_addr = 0xFFFFFFFF;
+ unsigned long the_addr;
+ unsigned short the_port;
+
+ _XLockMutex(_Xglobal_lock);
+ the_addr = unix_addr--;
+ _XUnlockMutex(_Xglobal_lock);
+ the_port = getpid ();
+
+ xdmcp_data[j++] = (the_addr >> 24) & 0xFF;
+ xdmcp_data[j++] = (the_addr >> 16) & 0xFF;
+ xdmcp_data[j++] = (the_addr >> 8) & 0xFF;
+ xdmcp_data[j++] = (the_addr >> 0) & 0xFF;
+ xdmcp_data[j++] = (the_port >> 8) & 0xFF;
+ xdmcp_data[j++] = (the_port >> 0) & 0xFF;
+ break;
+ }
+#endif /* AF_UNIX */
+#ifdef AF_DECnet
+ case AF_DECnet:
+ /*
+ * What is the defined encoding for this?
+ */
+ break;
+#endif /* AF_DECnet */
+ default:
+ /*
+ * Need to return some kind of errro status here.
+ * maybe a NULL auth??
+ */
+ break;
+ } /* switch */
+
+ if (addr)
+ free ((char *) addr);
+
+ time (&now);
+ xdmcp_data[j++] = (now >> 24) & 0xFF;
+ xdmcp_data[j++] = (now >> 16) & 0xFF;
+ xdmcp_data[j++] = (now >> 8) & 0xFF;
+ xdmcp_data[j++] = (now >> 0) & 0xFF;
+ while (j < 192 / 8)
+ xdmcp_data[j++] = 0;
+ _XLockMutex(_Xglobal_lock);
+ /* this function might use static data, hence the lock around it */
+ XdmcpWrap (xdmcp_data, auth_data + 8,
+ xdmcp_data, j);
+ _XUnlockMutex(_Xglobal_lock);
+ auth_data = xdmcp_data;
+ auth_datalen = j;
+ }
+#endif /* HASXDMAUTH */
+#ifdef SECURE_RPC
+ /*
+ * The SUN-DES-1 authorization protocol uses the
+ * "secure RPC" mechanism in SunOS 4.0+.
+ */
+ if (auth_namelen == 9 && !strncmp(auth_name, "SUN-DES-1", 9)) {
+ char servernetname[MAXNETNAMELEN + 1];
+
+ /*
+ * Copy over the server's netname from the authorization
+ * data field filled in by XauGetAuthByAddr().
+ */
+ if (auth_datalen > MAXNETNAMELEN) {
+ auth_datalen = 0;
+ auth_data = NULL;
+ } else {
+ memcpy(servernetname, auth_data, auth_datalen);
+ servernetname[auth_datalen] = '\0';
+
+ auth_datalen = sizeof (rpc_cred);
+ if (auth_ezencode(servernetname, 100, rpc_cred,
+ &auth_datalen))
+ auth_data = rpc_cred;
+ else {
+ auth_datalen = 0;
+ auth_data = NULL;
+ }
+ }
+ }
+#endif
+ if (saddr) free ((char *) saddr);
+ if ((*auth_namelenp = auth_namelen))
+ {
+ if ((*auth_namep = Xmalloc(auth_namelen)))
+ memcpy(*auth_namep, auth_name, auth_namelen);
+ else
+ *auth_namelenp = 0;
+ }
+ else
+ *auth_namep = NULL;
+ if ((*auth_datalenp = auth_datalen))
+ {
+ if ((*auth_datap = Xmalloc(auth_datalen)))
+ memcpy(*auth_datap, auth_data, auth_datalen);
+ else
+ *auth_datalenp = 0;
+ }
+ else
+ *auth_datap = NULL;
+ if (authptr) XauDisposeAuth (authptr);
+}
diff --git a/src/Context.c b/src/Context.c
new file mode 100644
index 00000000..f924c258
--- /dev/null
+++ b/src/Context.c
@@ -0,0 +1,317 @@
+/* $Xorg: Context.c,v 1.5 2001/02/09 02:03:31 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1987, 1988, 1990 by Digital Equipment Corporation, Maynard,
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/*
+
+Copyright 1987, 1988, 1990, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+/* This module implements a simple sparse array.
+
+ XSaveContext(a,b,c,d) will store d in position (a,b,c) of the array.
+ XFindContext(a,b,c,&d) will set d to be the value in position (a,b,c).
+ XDeleteContext(a,b,c) will delete the entry in (a,b,c).
+
+ a is a display id, b is a resource id, and c is a Context. d is just an
+ XPointer. This code will work with any range of parameters, but is geared
+ to be most efficient with very few (one or two) different a's.
+
+*/
+
+#include "Xlibint.h"
+#include "Xutil.h"
+#ifdef XTHREADS
+#include "locking.h"
+#endif
+
+#define INITHASHMASK 63 /* Number of entries originally in the hash table. */
+
+typedef struct _TableEntryRec { /* Stores one entry. */
+ XID rid;
+ XContext context;
+ XPointer data;
+ struct _TableEntryRec *next;
+} TableEntryRec, *TableEntry;
+
+typedef struct _XContextDB { /* Stores hash table for one display. */
+ TableEntry *table; /* Pointer to array of hash entries. */
+ int mask; /* Current size of hash table minus 1. */
+ int numentries; /* Number of entries currently in table. */
+#ifdef XTHREADS
+ LockInfoRec linfo;
+#endif
+} DBRec, *DB;
+
+#ifdef MOTIFBC
+static DB NullDB = (DB)0;
+#endif
+
+/* Given an XID and a context, returns a value between 0 and HashSize-1.
+ Currently, this requires that HashSize be a power of 2.
+*/
+
+#define Hash(db,rid,context) \
+ (db)->table[(((rid) << 1) + context) & (db)->mask]
+
+/* Resize the given db */
+
+static void ResizeTable(db)
+ register DB db;
+{
+ TableEntry *otable;
+ register TableEntry entry, next, *pold, *head;
+ register int i, j;
+
+ otable = db->table;
+ for (i = INITHASHMASK+1; (i + i) < db->numentries; )
+ i += i;
+ db->table = (TableEntry *) Xcalloc((unsigned)i, sizeof(TableEntry));
+ if (!db->table) {
+ db->table = otable;
+ return;
+ }
+ j = db->mask + 1;
+ db->mask = i - 1;
+ for (pold = otable ; --j >= 0; pold++) {
+ for (entry = *pold; entry; entry = next) {
+ next = entry->next;
+ head = &Hash(db, entry->rid, entry->context);
+ entry->next = *head;
+ *head = entry;
+ }
+ }
+ Xfree((char *) otable);
+}
+
+static void _XFreeContextDB(display)
+ Display *display;
+{
+ register DB db;
+ register int i;
+ register TableEntry *pentry, entry, next;
+
+ db = display->context_db;
+ if (db) {
+ for (i = db->mask + 1, pentry = db->table ; --i >= 0; pentry++) {
+ for (entry = *pentry; entry; entry = next) {
+ next = entry->next;
+ Xfree((char *)entry);
+ }
+ }
+ Xfree((char *) db->table);
+ _XFreeMutex(&db->linfo);
+ Xfree((char *) db);
+ }
+}
+
+/* Public routines. */
+
+/* Save the given value of data to correspond with the keys XID and context.
+ Returns nonzero error code if an error has occured, 0 otherwise.
+ Possible errors are Out-of-memory.
+*/
+
+#if NeedFunctionPrototypes
+int XSaveContext(
+ Display *display,
+ register XID rid,
+ register XContext context,
+ _Xconst char* data)
+#else
+int XSaveContext(display, rid, context, data)
+ Display *display;
+ register XID rid;
+ register XContext context;
+ XPointer data;
+#endif
+{
+ DB *pdb;
+ register DB db;
+ TableEntry *head;
+ register TableEntry entry;
+
+#ifdef MOTIFBC
+ if (!display) {
+ pdb = &NullDB;
+ db = *pdb;
+ } else
+#endif
+ {
+ LockDisplay(display);
+ pdb = &display->context_db;
+ db = *pdb;
+ UnlockDisplay(display);
+ }
+ if (!db) {
+ db = (DB) Xmalloc(sizeof(DBRec));
+ if (!db)
+ return XCNOMEM;
+ db->mask = INITHASHMASK;
+ db->table = (TableEntry *)Xcalloc(db->mask + 1, sizeof(TableEntry));
+ if (!db->table) {
+ Xfree((char *)db);
+ return XCNOMEM;
+ }
+ db->numentries = 0;
+ _XCreateMutex(&db->linfo);
+#ifdef MOTIFBC
+ if (!display) *pdb = db; else
+#endif
+ {
+ LockDisplay(display);
+ *pdb = db;
+ display->free_funcs->context_db = _XFreeContextDB;
+ UnlockDisplay(display);
+ }
+ }
+ _XLockMutex(&db->linfo);
+ head = &Hash(db, rid, context);
+ _XUnlockMutex(&db->linfo);
+ for (entry = *head; entry; entry = entry->next) {
+ if (entry->rid == rid && entry->context == context) {
+ entry->data = (XPointer)data;
+ return 0;
+ }
+ }
+ entry = (TableEntry) Xmalloc(sizeof(TableEntryRec));
+ if (!entry)
+ return XCNOMEM;
+ entry->rid = rid;
+ entry->context = context;
+ entry->data = (XPointer)data;
+ entry->next = *head;
+ *head = entry;
+ _XLockMutex(&db->linfo);
+ db->numentries++;
+ if (db->numentries > (db->mask << 2))
+ ResizeTable(db);
+ _XUnlockMutex(&db->linfo);
+ return 0;
+}
+
+
+
+/* Given an XID and context, returns the associated data. Note that data
+ here is a pointer since it is a return value. Returns nonzero error code
+ if an error has occured, 0 otherwise. Possible errors are Entry-not-found.
+*/
+
+int XFindContext(display, rid, context, data)
+ Display *display;
+ register XID rid;
+ register XContext context;
+ XPointer *data; /* RETURN */
+{
+ register DB db;
+ register TableEntry entry;
+
+#ifdef MOTIFBC
+ if (!display) db = NullDB; else
+#endif
+ {
+ LockDisplay(display);
+ db = display->context_db;
+ UnlockDisplay(display);
+ }
+ if (!db)
+ return XCNOENT;
+ _XLockMutex(&db->linfo);
+ for (entry = Hash(db, rid, context); entry; entry = entry->next)
+ {
+ if (entry->rid == rid && entry->context == context) {
+ *data = (XPointer)entry->data;
+ _XUnlockMutex(&db->linfo);
+ return 0;
+ }
+ }
+ _XUnlockMutex(&db->linfo);
+ return XCNOENT;
+}
+
+
+
+/* Deletes the entry for the given XID and context from the datastructure.
+ This returns the same thing that FindContext would have returned if called
+ with the same arguments.
+*/
+
+int XDeleteContext(display, rid, context)
+ Display *display;
+ register XID rid;
+ register XContext context;
+{
+ register DB db;
+ register TableEntry entry, *prev;
+
+#ifdef MOTIFBC
+ if (!display) db = NullDB; else
+#endif
+ {
+ LockDisplay(display);
+ db = display->context_db;
+ UnlockDisplay(display);
+ }
+ if (!db)
+ return XCNOENT;
+ _XLockMutex(&db->linfo);
+ for (prev = &Hash(db, rid, context);
+ (entry = *prev);
+ prev = &entry->next) {
+ if (entry->rid == rid && entry->context == context) {
+ *prev = entry->next;
+ Xfree((char *) entry);
+ db->numentries--;
+ if (db->numentries < db->mask && db->mask > INITHASHMASK)
+ ResizeTable(db);
+ _XUnlockMutex(&db->linfo);
+ return 0;
+ }
+ }
+ _XUnlockMutex(&db->linfo);
+ return XCNOENT;
+}
diff --git a/src/ConvSel.c b/src/ConvSel.c
new file mode 100644
index 00000000..b7148a98
--- /dev/null
+++ b/src/ConvSel.c
@@ -0,0 +1,49 @@
+/* $Xorg: ConvSel.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986,1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XConvertSelection(dpy, selection, target, property, requestor, time)
+register Display *dpy;
+Atom selection, target;
+Atom property;
+Window requestor;
+Time time;
+{
+ register xConvertSelectionReq *req;
+
+ LockDisplay(dpy);
+ GetReq(ConvertSelection, req);
+ req->selection = selection;
+ req->target = target;
+ req->property = property;
+ req->requestor = requestor;
+ req->time = time;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/CopyArea.c b/src/CopyArea.c
new file mode 100644
index 00000000..5a4c42ba
--- /dev/null
+++ b/src/CopyArea.c
@@ -0,0 +1,59 @@
+/* $Xorg: CopyArea.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XCopyArea(dpy, src_drawable, dst_drawable, gc,
+ src_x, src_y, width, height,
+ dst_x, dst_y)
+ register Display *dpy;
+ Drawable src_drawable, dst_drawable;
+ GC gc;
+ int src_x, src_y;
+ unsigned int width, height;
+ int dst_x, dst_y;
+
+{
+ register xCopyAreaReq *req;
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+ GetReq(CopyArea, req);
+ req->srcDrawable = src_drawable;
+ req->dstDrawable = dst_drawable;
+ req->gc = gc->gid;
+ req->srcX = src_x;
+ req->srcY = src_y;
+ req->dstX = dst_x;
+ req->dstY = dst_y;
+ req->width = width;
+ req->height = height;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/CopyCmap.c b/src/CopyCmap.c
new file mode 100644
index 00000000..a6873765
--- /dev/null
+++ b/src/CopyCmap.c
@@ -0,0 +1,49 @@
+/* $Xorg: CopyCmap.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+Colormap XCopyColormapAndFree(dpy, src_cmap)
+register Display *dpy;
+Colormap src_cmap;
+{
+ Colormap mid;
+ register xCopyColormapAndFreeReq *req;
+
+ LockDisplay(dpy);
+ GetReq(CopyColormapAndFree, req);
+
+ mid = req->mid = XAllocID(dpy);
+ req->srcCmap = src_cmap;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ _XcmsCopyCmapRecAndFree(dpy, src_cmap, mid);
+
+ return(mid);
+}
diff --git a/src/CopyGC.c b/src/CopyGC.c
new file mode 100644
index 00000000..ec228794
--- /dev/null
+++ b/src/CopyGC.c
@@ -0,0 +1,134 @@
+/* $Xorg: CopyGC.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XCopyGC (dpy, srcGC, mask, destGC)
+ register Display *dpy;
+ unsigned long mask; /* which ones to set initially */
+ GC srcGC, destGC;
+{
+ register XGCValues *destgv = &destGC->values,
+ *srcgv = &srcGC->values;
+ register xCopyGCReq *req;
+ register _XExtension *ext;
+
+ LockDisplay(dpy);
+
+ mask &= (1L << (GCLastBit + 1)) - 1;
+ /* if some of the source values to be copied are "dirty", flush them
+ out before sending the CopyGC request. */
+ if (srcGC->dirty & mask)
+ _XFlushGCCache(dpy, srcGC);
+
+ /* mark the copied values "not dirty" in the destination. */
+ destGC->dirty &= ~mask;
+
+ GetReq(CopyGC, req);
+ req->srcGC = srcGC->gid;
+ req->dstGC = destGC->gid;
+ req->mask = mask;
+
+ if (mask & GCFunction)
+ destgv->function = srcgv->function;
+
+ if (mask & GCPlaneMask)
+ destgv->plane_mask = srcgv->plane_mask;
+
+ if (mask & GCForeground)
+ destgv->foreground = srcgv->foreground;
+
+ if (mask & GCBackground)
+ destgv->background = srcgv->background;
+
+ if (mask & GCLineWidth)
+ destgv->line_width = srcgv->line_width;
+
+ if (mask & GCLineStyle)
+ destgv->line_style = srcgv->line_style;
+
+ if (mask & GCCapStyle)
+ destgv->cap_style = srcgv->cap_style;
+
+ if (mask & GCJoinStyle)
+ destgv->join_style = srcgv->join_style;
+
+ if (mask & GCFillStyle)
+ destgv->fill_style = srcgv->fill_style;
+
+ if (mask & GCFillRule)
+ destgv->fill_rule = srcgv->fill_rule;
+
+ if (mask & GCArcMode)
+ destgv->arc_mode = srcgv->arc_mode;
+
+ if (mask & GCTile)
+ destgv->tile = srcgv->tile;
+
+ if (mask & GCStipple)
+ destgv->stipple = srcgv->stipple;
+
+ if (mask & GCTileStipXOrigin)
+ destgv->ts_x_origin = srcgv->ts_x_origin;
+
+ if (mask & GCTileStipYOrigin)
+ destgv->ts_y_origin = srcgv->ts_y_origin;
+
+ if (mask & GCFont)
+ destgv->font = srcgv->font;
+
+ if (mask & GCSubwindowMode)
+ destgv->subwindow_mode = srcgv->subwindow_mode;
+
+ if (mask & GCGraphicsExposures)
+ destgv->graphics_exposures = srcgv->graphics_exposures;
+
+ if (mask & GCClipXOrigin)
+ destgv->clip_x_origin = srcgv->clip_x_origin;
+
+ if (mask & GCClipYOrigin)
+ destgv->clip_y_origin = srcgv->clip_y_origin;
+
+ if (mask & GCClipMask) {
+ destGC->rects = srcGC->rects;
+ destgv->clip_mask = srcgv->clip_mask;
+ }
+
+ if (mask & GCDashOffset)
+ destgv->dash_offset = srcgv->dash_offset;
+
+ if (mask & GCDashList) {
+ destGC->dashes = srcGC->dashes;
+ destgv->dashes = srcgv->dashes;
+ }
+ /* call out to any extensions interested */
+ for (ext = dpy->ext_procs; ext; ext = ext->next)
+ if (ext->copy_GC) (*ext->copy_GC)(dpy, destGC, &ext->codes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+ }
diff --git a/src/CopyPlane.c b/src/CopyPlane.c
new file mode 100644
index 00000000..1df2b14a
--- /dev/null
+++ b/src/CopyPlane.c
@@ -0,0 +1,61 @@
+/* $Xorg: CopyPlane.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XCopyPlane(dpy, src_drawable, dst_drawable, gc,
+ src_x, src_y, width, height,
+ dst_x, dst_y, bit_plane)
+ register Display *dpy;
+ Drawable src_drawable, dst_drawable;
+ GC gc;
+ int src_x, src_y;
+ unsigned int width, height;
+ int dst_x, dst_y;
+ unsigned long bit_plane;
+
+{
+ register xCopyPlaneReq *req;
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+ GetReq(CopyPlane, req);
+ req->srcDrawable = src_drawable;
+ req->dstDrawable = dst_drawable;
+ req->gc = gc->gid;
+ req->srcX = src_x;
+ req->srcY = src_y;
+ req->dstX = dst_x;
+ req->dstY = dst_y;
+ req->width = width;
+ req->height = height;
+ req->bitPlane = bit_plane;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/CrBFData.c b/src/CrBFData.c
new file mode 100644
index 00000000..70060a96
--- /dev/null
+++ b/src/CrBFData.c
@@ -0,0 +1,85 @@
+/* $Xorg: CrBFData.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlib.h"
+
+/*
+ * XCreateBitmapFromData: Routine to make a pixmap of depth 1 from user
+ * supplied data.
+ * D is any drawable on the same screen that the pixmap will be used in.
+ * Data is a pointer to the bit data, and
+ * width & height give the size in bits of the pixmap.
+ *
+ * The following format is assumed for data:
+ *
+ * format=XYPixmap
+ * bit_order=LSBFirst
+ * byte_order=LSBFirst
+ * padding=8
+ * bitmap_unit=8
+ * xoffset=0
+ * no extra bytes per line
+ */
+#if NeedFunctionPrototypes
+Pixmap XCreateBitmapFromData(
+ Display *display,
+ Drawable d,
+ _Xconst char *data,
+ unsigned int width,
+ unsigned int height)
+#else
+Pixmap XCreateBitmapFromData(display, d, data, width, height)
+ Display *display;
+ Drawable d;
+ char *data;
+ unsigned int width, height;
+#endif
+{
+ XImage ximage;
+ GC gc;
+ Pixmap pix;
+
+ pix = XCreatePixmap(display, d, width, height, 1);
+ if (! (gc = XCreateGC(display, pix, (unsigned long) 0, (XGCValues *) 0)))
+ return (Pixmap) None;
+ ximage.height = height;
+ ximage.width = width;
+ ximage.depth = 1;
+ ximage.bits_per_pixel = 1;
+ ximage.xoffset = 0;
+ ximage.format = XYPixmap;
+ ximage.data = (char *)data;
+ ximage.byte_order = LSBFirst;
+ ximage.bitmap_unit = 8;
+ ximage.bitmap_bit_order = LSBFirst;
+ ximage.bitmap_pad = 8;
+ ximage.bytes_per_line = (width+7)/8;
+
+ XPutImage(display, pix, gc, &ximage, 0, 0, 0, 0, width, height);
+ XFreeGC(display, gc);
+ return(pix);
+}
diff --git a/src/CrCmap.c b/src/CrCmap.c
new file mode 100644
index 00000000..3c1878df
--- /dev/null
+++ b/src/CrCmap.c
@@ -0,0 +1,53 @@
+/* $Xorg: CrCmap.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+Colormap XCreateColormap(dpy, w, visual, alloc)
+register Display *dpy;
+Window w;
+Visual *visual;
+int alloc;
+{
+ register xCreateColormapReq *req;
+ Colormap mid;
+
+ LockDisplay(dpy);
+ GetReq(CreateColormap, req);
+ req->window = w;
+ mid = req->mid = XAllocID(dpy);
+ req->alloc = alloc;
+ if (visual == CopyFromParent) req->visual = CopyFromParent;
+ else req->visual = visual->visualid;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ _XcmsAddCmapRec(dpy, mid, w, visual);
+
+ return(mid);
+}
diff --git a/src/CrCursor.c b/src/CrCursor.c
new file mode 100644
index 00000000..93c7a006
--- /dev/null
+++ b/src/CrCursor.c
@@ -0,0 +1,57 @@
+/* $Xorg: CrCursor.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+Cursor XCreatePixmapCursor(dpy, source, mask, foreground, background, x, y)
+ register Display *dpy;
+ Pixmap source, mask;
+ XColor *foreground, *background;
+ unsigned int x, y;
+
+{
+ register xCreateCursorReq *req;
+ Cursor cid;
+
+ LockDisplay(dpy);
+ GetReq(CreateCursor, req);
+ req->cid = cid = XAllocID(dpy);
+ req->source = source;
+ req->mask = mask;
+ req->foreRed = foreground->red;
+ req->foreGreen = foreground->green;
+ req->foreBlue = foreground->blue;
+ req->backRed = background->red;
+ req->backGreen = background->green;
+ req->backBlue = background->blue;
+ req->x = x;
+ req->y = y;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (cid);
+}
+
diff --git a/src/CrGC.c b/src/CrGC.c
new file mode 100644
index 00000000..969f6d88
--- /dev/null
+++ b/src/CrGC.c
@@ -0,0 +1,342 @@
+/* $Xorg: CrGC.c,v 1.5 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+#ifdef __STDC__
+#define Const const
+#else
+#define Const /**/
+#endif
+
+static XGCValues Const initial_GC = {
+ GXcopy, /* function */
+ AllPlanes, /* plane_mask */
+ 0L, /* foreground */
+ 1L, /* background */
+ 0, /* line_width */
+ LineSolid, /* line_style */
+ CapButt, /* cap_style */
+ JoinMiter, /* join_style */
+ FillSolid, /* fill_style */
+ EvenOddRule,/* fill_rule */
+ ArcPieSlice,/* arc_mode */
+ (Pixmap)~0L,/* tile, impossible (unknown) resource */
+ (Pixmap)~0L,/* stipple, impossible (unknown) resource */
+ 0, /* ts_x_origin */
+ 0, /* ts_y_origin */
+ (Font)~0L, /* font, impossible (unknown) resource */
+ ClipByChildren, /* subwindow_mode */
+ True, /* graphics_exposures */
+ 0, /* clip_x_origin */
+ 0, /* clip_y_origin */
+ None, /* clip_mask */
+ 0, /* dash_offset */
+ 4 /* dashes (list [4,4]) */
+};
+
+static void _XGenerateGCList();
+
+GC XCreateGC (dpy, d, valuemask, values)
+ register Display *dpy;
+ Drawable d; /* Window or Pixmap for which depth matches */
+ unsigned long valuemask; /* which ones to set initially */
+ XGCValues *values; /* the values themselves */
+{
+ register GC gc;
+ register xCreateGCReq *req;
+ register _XExtension *ext;
+
+ LockDisplay(dpy);
+ if ((gc = (GC)Xmalloc (sizeof(struct _XGC))) == NULL) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (NULL);
+ }
+ gc->rects = 0;
+ gc->dashes = 0;
+ gc->ext_data = NULL;
+ gc->values = initial_GC;
+ gc->dirty = 0L;
+
+ valuemask &= (1L << (GCLastBit + 1)) - 1;
+ if (valuemask) _XUpdateGCCache (gc, valuemask, values);
+
+ GetReq(CreateGC, req);
+ req->drawable = d;
+ req->gc = gc->gid = XAllocID(dpy);
+
+ if ((req->mask = gc->dirty))
+ _XGenerateGCList (dpy, gc, (xReq *) req);
+ /* call out to any extensions interested */
+ for (ext = dpy->ext_procs; ext; ext = ext->next)
+ if (ext->create_GC) (*ext->create_GC)(dpy, gc, &ext->codes);
+ gc->dirty = 0L; /* allow extensions to see dirty bits */
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (gc);
+ }
+
+/*
+ * GenerateGCList looks at the GC dirty bits, and appends all the required
+ * long words to the request being generated.
+ */
+
+static void
+_XGenerateGCList (dpy, gc, req)
+ register Display *dpy;
+ xReq *req;
+ GC gc;
+ {
+ unsigned long values[32];
+ register unsigned long *value = values;
+ long nvalues;
+ register XGCValues *gv = &gc->values;
+ register unsigned long dirty = gc->dirty;
+
+ /*
+ * Note: The order of these tests are critical; the order must be the
+ * same as the GC mask bits in the word.
+ */
+ if (dirty & GCFunction) *value++ = gv->function;
+ if (dirty & GCPlaneMask) *value++ = gv->plane_mask;
+ if (dirty & GCForeground) *value++ = gv->foreground;
+ if (dirty & GCBackground) *value++ = gv->background;
+ if (dirty & GCLineWidth) *value++ = gv->line_width;
+ if (dirty & GCLineStyle) *value++ = gv->line_style;
+ if (dirty & GCCapStyle) *value++ = gv->cap_style;
+ if (dirty & GCJoinStyle) *value++ = gv->join_style;
+ if (dirty & GCFillStyle) *value++ = gv->fill_style;
+ if (dirty & GCFillRule) *value++ = gv->fill_rule;
+ if (dirty & GCTile) *value++ = gv->tile;
+ if (dirty & GCStipple) *value++ = gv->stipple;
+ if (dirty & GCTileStipXOrigin) *value++ = gv->ts_x_origin;
+ if (dirty & GCTileStipYOrigin) *value++ = gv->ts_y_origin;
+ if (dirty & GCFont) *value++ = gv->font;
+ if (dirty & GCSubwindowMode) *value++ = gv->subwindow_mode;
+ if (dirty & GCGraphicsExposures) *value++ = gv->graphics_exposures;
+ if (dirty & GCClipXOrigin) *value++ = gv->clip_x_origin;
+ if (dirty & GCClipYOrigin) *value++ = gv->clip_y_origin;
+ if (dirty & GCClipMask) *value++ = gv->clip_mask;
+ if (dirty & GCDashOffset) *value++ = gv->dash_offset;
+ if (dirty & GCDashList) *value++ = gv->dashes;
+ if (dirty & GCArcMode) *value++ = gv->arc_mode;
+
+ req->length += (nvalues = value - values);
+
+ /*
+ * note: Data is a macro that uses its arguments multiple
+ * times, so "nvalues" is changed in a separate assignment
+ * statement
+ */
+
+ nvalues <<= 2;
+ Data32 (dpy, (long *) values, nvalues);
+
+ }
+
+
+_XUpdateGCCache (gc, mask, attr)
+ register unsigned long mask;
+ register XGCValues *attr;
+ register GC gc;
+ {
+ register XGCValues *gv = &gc->values;
+
+ if (mask & GCFunction)
+ if (gv->function != attr->function) {
+ gv->function = attr->function;
+ gc->dirty |= GCFunction;
+ }
+
+ if (mask & GCPlaneMask)
+ if (gv->plane_mask != attr->plane_mask) {
+ gv->plane_mask = attr->plane_mask;
+ gc->dirty |= GCPlaneMask;
+ }
+
+ if (mask & GCForeground)
+ if (gv->foreground != attr->foreground) {
+ gv->foreground = attr->foreground;
+ gc->dirty |= GCForeground;
+ }
+
+ if (mask & GCBackground)
+ if (gv->background != attr->background) {
+ gv->background = attr->background;
+ gc->dirty |= GCBackground;
+ }
+
+ if (mask & GCLineWidth)
+ if (gv->line_width != attr->line_width) {
+ gv->line_width = attr->line_width;
+ gc->dirty |= GCLineWidth;
+ }
+
+ if (mask & GCLineStyle)
+ if (gv->line_style != attr->line_style) {
+ gv->line_style = attr->line_style;
+ gc->dirty |= GCLineStyle;
+ }
+
+ if (mask & GCCapStyle)
+ if (gv->cap_style != attr->cap_style) {
+ gv->cap_style = attr->cap_style;
+ gc->dirty |= GCCapStyle;
+ }
+
+ if (mask & GCJoinStyle)
+ if (gv->join_style != attr->join_style) {
+ gv->join_style = attr->join_style;
+ gc->dirty |= GCJoinStyle;
+ }
+
+ if (mask & GCFillStyle)
+ if (gv->fill_style != attr->fill_style) {
+ gv->fill_style = attr->fill_style;
+ gc->dirty |= GCFillStyle;
+ }
+
+ if (mask & GCFillRule)
+ if (gv->fill_rule != attr->fill_rule) {
+ gv->fill_rule = attr->fill_rule;
+ gc->dirty |= GCFillRule;
+ }
+
+ if (mask & GCArcMode)
+ if (gv->arc_mode != attr->arc_mode) {
+ gv->arc_mode = attr->arc_mode;
+ gc->dirty |= GCArcMode;
+ }
+
+ /* always write through tile change, since client may have changed pixmap contents */
+ if (mask & GCTile) {
+ gv->tile = attr->tile;
+ gc->dirty |= GCTile;
+ }
+
+ /* always write through stipple change, since client may have changed pixmap contents */
+ if (mask & GCStipple) {
+ gv->stipple = attr->stipple;
+ gc->dirty |= GCStipple;
+ }
+
+ if (mask & GCTileStipXOrigin)
+ if (gv->ts_x_origin != attr->ts_x_origin) {
+ gv->ts_x_origin = attr->ts_x_origin;
+ gc->dirty |= GCTileStipXOrigin;
+ }
+
+ if (mask & GCTileStipYOrigin)
+ if (gv->ts_y_origin != attr->ts_y_origin) {
+ gv->ts_y_origin = attr->ts_y_origin;
+ gc->dirty |= GCTileStipYOrigin;
+ }
+
+ if (mask & GCFont)
+ if (gv->font != attr->font) {
+ gv->font = attr->font;
+ gc->dirty |= GCFont;
+ }
+
+ if (mask & GCSubwindowMode)
+ if (gv->subwindow_mode != attr->subwindow_mode) {
+ gv->subwindow_mode = attr->subwindow_mode;
+ gc->dirty |= GCSubwindowMode;
+ }
+
+ if (mask & GCGraphicsExposures)
+ if (gv->graphics_exposures != attr->graphics_exposures) {
+ gv->graphics_exposures = attr->graphics_exposures;
+ gc->dirty |= GCGraphicsExposures;
+ }
+
+ if (mask & GCClipXOrigin)
+ if (gv->clip_x_origin != attr->clip_x_origin) {
+ gv->clip_x_origin = attr->clip_x_origin;
+ gc->dirty |= GCClipXOrigin;
+ }
+
+ if (mask & GCClipYOrigin)
+ if (gv->clip_y_origin != attr->clip_y_origin) {
+ gv->clip_y_origin = attr->clip_y_origin;
+ gc->dirty |= GCClipYOrigin;
+ }
+
+ /* always write through mask change, since client may have changed pixmap contents */
+ if (mask & GCClipMask) {
+ gv->clip_mask = attr->clip_mask;
+ gc->dirty |= GCClipMask;
+ gc->rects = 0;
+ }
+
+ if (mask & GCDashOffset)
+ if (gv->dash_offset != attr->dash_offset) {
+ gv->dash_offset = attr->dash_offset;
+ gc->dirty |= GCDashOffset;
+ }
+
+ if (mask & GCDashList)
+ if ((gv->dashes != attr->dashes) || (gc->dashes == True)) {
+ gv->dashes = attr->dashes;
+ gc->dirty |= GCDashList;
+ gc->dashes = 0;
+ }
+ return 0;
+ }
+
+/* can only call when display is already locked. */
+
+void _XFlushGCCache(dpy, gc)
+ Display *dpy;
+ GC gc;
+{
+ register xChangeGCReq *req;
+ register _XExtension *ext;
+
+ if (gc->dirty) {
+ GetReq(ChangeGC, req);
+ req->gc = gc->gid;
+ req->mask = gc->dirty;
+ _XGenerateGCList (dpy, gc, (xReq *) req);
+ /* call out to any extensions interested */
+ for (ext = dpy->ext_procs; ext; ext = ext->next)
+ if (ext->flush_GC) (*ext->flush_GC)(dpy, gc, &ext->codes);
+ gc->dirty = 0L; /* allow extensions to see dirty bits */
+ }
+}
+
+void XFlushGC(dpy, gc)
+ Display *dpy;
+ GC gc;
+{
+ FlushGC(dpy, gc);
+}
+
+GContext XGContextFromGC(gc)
+ GC gc;
+ { return (gc->gid); }
diff --git a/src/CrGlCur.c b/src/CrGlCur.c
new file mode 100644
index 00000000..d6fc4039
--- /dev/null
+++ b/src/CrGlCur.c
@@ -0,0 +1,59 @@
+/* $Xorg: CrGlCur.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+Cursor XCreateGlyphCursor(dpy, source_font, mask_font,
+ source_char, mask_char,
+ foreground, background)
+ register Display *dpy;
+ Font source_font, mask_font;
+ unsigned int source_char, mask_char;
+ XColor *foreground, *background;
+
+{
+ Cursor cid;
+ register xCreateGlyphCursorReq *req;
+
+ LockDisplay(dpy);
+ GetReq(CreateGlyphCursor, req);
+ cid = req->cid = XAllocID(dpy);
+ req->source = source_font;
+ req->mask = mask_font;
+ req->sourceChar = source_char;
+ req->maskChar = mask_char;
+ req->foreRed = foreground->red;
+ req->foreGreen = foreground->green;
+ req->foreBlue = foreground->blue;
+ req->backRed = background->red;
+ req->backGreen = background->green;
+ req->backBlue = background->blue;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (cid);
+}
+
diff --git a/src/CrPFBData.c b/src/CrPFBData.c
new file mode 100644
index 00000000..f28aabbb
--- /dev/null
+++ b/src/CrPFBData.c
@@ -0,0 +1,83 @@
+/* $Xorg: CrPFBData.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlib.h"
+#include <stdio.h>
+
+/*
+ * XCreatePixmapFromBitmapData: Routine to make a pixmap from user supplied bitmap data.
+ * D is any drawable on the same screen that the pixmap will be used in.
+ * Data is a pointer to the bit data, and
+ * width & height give the size in bits of the pixmap.
+ * Fg and Bg are the pixel values to use for the two colors.
+ * Depth is the depth of the pixmap to create.
+ *
+ * The following format is assumed for data:
+ *
+ * format=XYPixmap
+ * bit_order=LSBFirst
+ * byte_order=LSBFirst
+ * padding=8
+ * bitmap_unit=8
+ * xoffset=0
+ * no extra bytes per line
+ */
+Pixmap XCreatePixmapFromBitmapData(display,d,data,width,height,fg,bg,depth)
+ Display *display;
+ Drawable d;
+ char *data;
+ unsigned int width, height;
+ unsigned long fg, bg;
+ unsigned int depth;
+{
+ XImage ximage;
+ GC gc;
+ XGCValues gcv;
+ Pixmap pix;
+
+ pix = XCreatePixmap(display, d, width, height, depth);
+ gcv.foreground = fg;
+ gcv.background = bg;
+ if (! (gc = XCreateGC(display, pix, GCForeground|GCBackground, &gcv)))
+ return (Pixmap) NULL;
+ ximage.height = height;
+ ximage.width = width;
+ ximage.depth = 1;
+ ximage.bits_per_pixel = 1;
+ ximage.xoffset = 0;
+ ximage.format = XYBitmap;
+ ximage.data = data;
+ ximage.byte_order = LSBFirst;
+ ximage.bitmap_unit = 8;
+ ximage.bitmap_bit_order = LSBFirst;
+ ximage.bitmap_pad = 8;
+ ximage.bytes_per_line = (width+7)/8;
+
+ XPutImage(display, pix, gc, &ximage, 0, 0, 0, 0, width, height);
+ XFreeGC(display, gc);
+ return(pix);
+}
diff --git a/src/CrPixmap.c b/src/CrPixmap.c
new file mode 100644
index 00000000..2505f48a
--- /dev/null
+++ b/src/CrPixmap.c
@@ -0,0 +1,49 @@
+/* $Xorg: CrPixmap.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+Pixmap XCreatePixmap (dpy, d, width, height, depth)
+ register Display *dpy;
+ Drawable d;
+ unsigned int width, height, depth;
+{
+ Pixmap pid;
+ register xCreatePixmapReq *req;
+
+ LockDisplay(dpy);
+ GetReq(CreatePixmap, req);
+ req->drawable = d;
+ req->width = width;
+ req->height = height;
+ req->depth = depth;
+ pid = req->pid = XAllocID(dpy);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (pid);
+}
+
diff --git a/src/CrWindow.c b/src/CrWindow.c
new file mode 100644
index 00000000..418f9867
--- /dev/null
+++ b/src/CrWindow.c
@@ -0,0 +1,74 @@
+/* $Xorg: CrWindow.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+Window XCreateSimpleWindow(dpy, parent, x, y, width, height,
+ borderWidth, border, background)
+ register Display *dpy;
+ Window parent;
+ int x, y;
+ unsigned int width, height, borderWidth;
+ unsigned long border;
+ unsigned long background;
+{
+ Window wid;
+ register xCreateWindowReq *req;
+
+ LockDisplay(dpy);
+ GetReqExtra(CreateWindow, 8, req);
+ req->parent = parent;
+ req->x = x;
+ req->y = y;
+ req->width = width;
+ req->height = height;
+ req->borderWidth = borderWidth;
+ req->depth = 0;
+ req->class = CopyFromParent;
+ req->visual = CopyFromParent;
+ wid = req->wid = XAllocID(dpy);
+ req->mask = CWBackPixel | CWBorderPixel;
+
+#ifdef MUSTCOPY
+ {
+ unsigned long lbackground = background, lborder = border;
+ dpy->bufptr -= 8;
+ Data32 (dpy, (long *) &lbackground, 4);
+ Data32 (dpy, (long *) &lborder, 4);
+ }
+#else
+ {
+ register CARD32 *valuePtr = (CARD32 *) NEXTPTR(req,xCreateWindowReq);
+ *valuePtr++ = background;
+ *valuePtr = border;
+ }
+#endif /* MUSTCOPY */
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (wid);
+ }
diff --git a/src/Cursor.c b/src/Cursor.c
new file mode 100644
index 00000000..55ff456c
--- /dev/null
+++ b/src/Cursor.c
@@ -0,0 +1,51 @@
+/* $Xorg: Cursor.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+static XColor foreground = { 0, 0, 0, 0 }; /* black */
+static XColor background = { 0, 65535, 65535, 65535 }; /* white */
+
+Cursor XCreateFontCursor(dpy, which)
+ Display *dpy;
+ unsigned int which;
+{
+ /*
+ * the cursor font contains the shape glyph followed by the mask
+ * glyph; so character position 0 contains a shape, 1 the mask for 0,
+ * 2 a shape, etc. <X11/cursorfont.h> contains hash define names
+ * for all of these.
+ */
+
+ if (dpy->cursor_font == None) {
+ dpy->cursor_font = XLoadFont (dpy, CURSORFONT);
+ if (dpy->cursor_font == None) return None;
+ }
+
+ return XCreateGlyphCursor (dpy, dpy->cursor_font, dpy->cursor_font,
+ which, which + 1, &foreground, &background);
+}
+
diff --git a/src/DefCursor.c b/src/DefCursor.c
new file mode 100644
index 00000000..d4eadea2
--- /dev/null
+++ b/src/DefCursor.c
@@ -0,0 +1,46 @@
+/* $Xorg: DefCursor.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986,1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XDefineCursor (dpy, w, cursor)
+ register Display *dpy;
+ Window w;
+ Cursor cursor;
+{
+ register xChangeWindowAttributesReq *req;
+
+ LockDisplay(dpy);
+ GetReqExtra (ChangeWindowAttributes, 4, req);
+ req->window = w;
+ req->valueMask = CWCursor;
+ OneDataCard32 (dpy, NEXTPTR(req,xChangeWindowAttributesReq), cursor);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/DelProp.c b/src/DelProp.c
new file mode 100644
index 00000000..11bf3a3d
--- /dev/null
+++ b/src/DelProp.c
@@ -0,0 +1,44 @@
+/* $Xorg: DelProp.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XDeleteProperty(dpy, window, property)
+register Display *dpy;
+Window window;
+Atom property;
+{
+ register xDeletePropertyReq *req;
+
+ LockDisplay(dpy);
+ GetReq(DeleteProperty, req);
+ req->window = window;
+ req->property = property;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/Depths.c b/src/Depths.c
new file mode 100644
index 00000000..34756e71
--- /dev/null
+++ b/src/Depths.c
@@ -0,0 +1,60 @@
+/* $Xorg: Depths.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+#include <stdio.h>
+
+/*
+ * XListDepths - return info from connection setup
+ */
+int *XListDepths (dpy, scrnum, countp)
+ Display *dpy;
+ int scrnum;
+ int *countp;
+{
+ Screen *scr;
+ int count;
+ int *depths;
+
+ if (scrnum < 0 || scrnum >= dpy->nscreens) return NULL;
+
+ scr = &dpy->screens[scrnum];
+ if ((count = scr->ndepths) > 0) {
+ register Depth *dp;
+ register int i;
+
+ depths = (int *) Xmalloc (count * sizeof(int));
+ if (!depths) return NULL;
+ for (i = 0, dp = scr->depths; i < count; i++, dp++)
+ depths[i] = dp->depth;
+ } else {
+ /* a screen must have a depth */
+ return NULL;
+ }
+ *countp = count;
+ return depths;
+}
diff --git a/src/DestSubs.c b/src/DestSubs.c
new file mode 100644
index 00000000..98aadd6b
--- /dev/null
+++ b/src/DestSubs.c
@@ -0,0 +1,42 @@
+/* $Xorg: DestSubs.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XDestroySubwindows(dpy, win)
+register Display *dpy;
+Window win;
+{
+ register xResourceReq *req;
+
+ LockDisplay(dpy);
+ GetResReq (DestroySubwindows,win, req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/DestWind.c b/src/DestWind.c
new file mode 100644
index 00000000..319e4ec3
--- /dev/null
+++ b/src/DestWind.c
@@ -0,0 +1,42 @@
+/* $Xorg: DestWind.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XDestroyWindow (dpy, w)
+ register Display *dpy;
+ Window w;
+{
+ register xResourceReq *req;
+
+ LockDisplay(dpy);
+ GetResReq(DestroyWindow, w, req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/DisName.c b/src/DisName.c
new file mode 100644
index 00000000..17ebf356
--- /dev/null
+++ b/src/DisName.c
@@ -0,0 +1,62 @@
+/* $Xorg: DisName.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+
+/*
+
+Copyright 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+/* 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>
+
+extern 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/src/DrArc.c b/src/DrArc.c
new file mode 100644
index 00000000..466e7e15
--- /dev/null
+++ b/src/DrArc.c
@@ -0,0 +1,79 @@
+/* $Xorg: DrArc.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/* Note to future maintainers: XDrawArc does NOT batch successive PolyArc
+ requests into a single request like XDrawLine, XDrawPoint, etc.
+ We don't do this because X_PolyArc applies the GC's join-style if
+ the last point in one arc coincides with the first point in another.
+ The client wouldn't expect this and would have no easy way to defeat it. */
+
+#include "Xlibint.h"
+
+XDrawArc(dpy, d, gc, x, y, width, height, angle1, angle2)
+ register Display *dpy;
+ Drawable d;
+ GC gc;
+ int x, y; /* INT16 */
+ unsigned int width, height; /* CARD16 */
+ int angle1, angle2; /* INT16 */
+{
+ register xPolyArcReq *req;
+ register xArc *arc;
+#ifdef MUSTCOPY
+ xArc arcdata;
+ long len = SIZEOF(xArc);
+
+ arc = &arcdata;
+#endif /* MUSTCOPY */
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+ GetReqExtra (PolyArc, SIZEOF(xArc), req);
+
+ req->drawable = d;
+ req->gc = gc->gid;
+
+#ifndef MUSTCOPY
+ arc = (xArc *) NEXTPTR(req,xPolyArcReq);
+#endif /* MUSTCOPY */
+
+ arc->x = x;
+ arc->y = y;
+ arc->width = width;
+ arc->height = height;
+ arc->angle1 = angle1;
+ arc->angle2 = angle2;
+
+#ifdef MUSTCOPY
+ dpy->bufptr -= SIZEOF(xArc);
+ Data (dpy, (char *) arc, len);
+#endif /* MUSTCOPY */
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/DrArcs.c b/src/DrArcs.c
new file mode 100644
index 00000000..9f8ef96a
--- /dev/null
+++ b/src/DrArcs.c
@@ -0,0 +1,54 @@
+/* $Xorg: DrArcs.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+#define arc_scale (SIZEOF(xArc) / 4)
+
+XDrawArcs(dpy, d, gc, arcs, n_arcs)
+register Display *dpy;
+Drawable d;
+GC gc;
+XArc *arcs;
+int n_arcs;
+{
+ register xPolyArcReq *req;
+ register long len;
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+ GetReq(PolyArc,req);
+ req->drawable = d;
+ req->gc = gc->gid;
+ len = ((long)n_arcs) * arc_scale;
+ SetReqLen(req, len, 1);
+ len <<= 2; /* watch out for macros... */
+ Data16 (dpy, (short *) arcs, len);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/DrLine.c b/src/DrLine.c
new file mode 100644
index 00000000..6b17fbe5
--- /dev/null
+++ b/src/DrLine.c
@@ -0,0 +1,95 @@
+/* $Xorg: DrLine.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+/* precompute the maximum size of batching request allowed */
+
+#define wsize (SIZEOF(xPolySegmentReq) + WLNSPERBATCH * SIZEOF(xSegment))
+#define zsize (SIZEOF(xPolySegmentReq) + ZLNSPERBATCH * SIZEOF(xSegment))
+
+XDrawLine (dpy, d, gc, x1, y1, x2, y2)
+ register Display *dpy;
+ Drawable d;
+ GC gc;
+ int x1, y1, x2, y2;
+{
+ register xSegment *segment;
+#ifdef MUSTCOPY
+ xSegment segmentdata;
+ long len = SIZEOF(xSegment);
+
+ segment = &segmentdata;
+#endif /* not MUSTCOPY */
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+
+ {
+ register xPolySegmentReq *req = (xPolySegmentReq *) dpy->last_req;
+
+ /* if same as previous request, with same drawable, batch requests */
+ if (
+ (req->reqType == X_PolySegment)
+ && (req->drawable == d)
+ && (req->gc == gc->gid)
+ && ((dpy->bufptr + SIZEOF(xSegment)) <= dpy->bufmax)
+ && (((char *)dpy->bufptr - (char *)req) < (gc->values.line_width ?
+ wsize : zsize)) ) {
+ req->length += SIZEOF(xSegment) >> 2;
+#ifndef MUSTCOPY
+ segment = (xSegment *) dpy->bufptr;
+ dpy->bufptr += SIZEOF(xSegment);
+#endif /* not MUSTCOPY */
+ }
+
+ else {
+ GetReqExtra (PolySegment, SIZEOF(xSegment), req);
+ req->drawable = d;
+ req->gc = gc->gid;
+#ifdef MUSTCOPY
+ dpy->bufptr -= SIZEOF(xSegment);
+#else
+ segment = (xSegment *) NEXTPTR(req,xPolySegmentReq);
+#endif /* MUSTCOPY */
+ }
+
+ segment->x1 = x1;
+ segment->y1 = y1;
+ segment->x2 = x2;
+ segment->y2 = y2;
+
+#ifdef MUSTCOPY
+ Data (dpy, (char *) &segmentdata, len);
+#endif /* MUSTCOPY */
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ }
+ return 1;
+}
+
diff --git a/src/DrLines.c b/src/DrLines.c
new file mode 100644
index 00000000..05b0d5d7
--- /dev/null
+++ b/src/DrLines.c
@@ -0,0 +1,54 @@
+/* $Xorg: DrLines.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XDrawLines (dpy, d, gc, points, npoints, mode)
+ register Display *dpy;
+ Drawable d;
+ GC gc;
+ XPoint *points;
+ int npoints;
+ int mode;
+{
+ register xPolyLineReq *req;
+ register long length;
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+ GetReq (PolyLine, req);
+ req->drawable = d;
+ req->gc = gc->gid;
+ req->coordMode = mode;
+ SetReqLen(req, npoints, 65535 - req->length);
+ /* each point is 2 16-bit integers */
+ length = npoints << 2; /* watch out for macros... */
+ Data16 (dpy, (short *) points, length);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/DrPoint.c b/src/DrPoint.c
new file mode 100644
index 00000000..390e9dad
--- /dev/null
+++ b/src/DrPoint.c
@@ -0,0 +1,93 @@
+/* $Xorg: DrPoint.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+/* precompute the maximum size of batching request allowed */
+
+#define size (SIZEOF(xPolyPointReq) + PTSPERBATCH * SIZEOF(xPoint))
+
+XDrawPoint(dpy, d, gc, x, y)
+ register Display *dpy;
+ Drawable d;
+ GC gc;
+ int x, y; /* INT16 */
+{
+ xPoint *point;
+#ifdef MUSTCOPY
+ xPoint pointdata;
+ long len = SIZEOF(xPoint);
+
+ point = &pointdata;
+#endif /* MUSTCOPY */
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+
+ {
+ register xPolyPointReq *req = (xPolyPointReq *) dpy->last_req;
+
+
+ /* if same as previous request, with same drawable, batch requests */
+ if (
+ (req->reqType == X_PolyPoint)
+ && (req->drawable == d)
+ && (req->gc == gc->gid)
+ && (req->coordMode == CoordModeOrigin)
+ && ((dpy->bufptr + SIZEOF(xPoint)) <= dpy->bufmax)
+ && (((char *)dpy->bufptr - (char *)req) < size) ) {
+ req->length += SIZEOF(xPoint) >> 2;
+#ifndef MUSTCOPY
+ point = (xPoint *) dpy->bufptr;
+ dpy->bufptr += SIZEOF(xPoint);
+#endif /* not MUSTCOPY */
+ }
+
+ else {
+ GetReqExtra(PolyPoint, 4, req); /* 1 point = 4 bytes */
+ req->drawable = d;
+ req->gc = gc->gid;
+ req->coordMode = CoordModeOrigin;
+#ifdef MUSTCOPY
+ dpy->bufptr -= SIZEOF(xPoint);
+#else
+ point = (xPoint *) NEXTPTR(req,xPolyPointReq);
+#endif /* MUSTCOPY */
+ }
+
+ point->x = x;
+ point->y = y;
+
+#ifdef MUSTCOPY
+ Data (dpy, (char *) point, len);
+#endif /* MUSTCOPY */
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/DrPoints.c b/src/DrPoints.c
new file mode 100644
index 00000000..c261be0d
--- /dev/null
+++ b/src/DrPoints.c
@@ -0,0 +1,82 @@
+/* $Xorg: DrPoints.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XDrawPoints(dpy, d, gc, points, n_points, mode)
+ register Display *dpy;
+ Drawable d;
+ GC gc;
+ XPoint *points;
+ int n_points;
+ int mode; /* CoordMode */
+{
+ register xPolyPointReq *req;
+ register long nbytes;
+ int n;
+ int xoff, yoff;
+ XPoint pt;
+
+ xoff = yoff = 0;
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+ while (n_points) {
+ GetReq(PolyPoint, req);
+ req->drawable = d;
+ req->gc = gc->gid;
+ req->coordMode = mode;
+ n = n_points;
+ if (!dpy->bigreq_size && n > (dpy->max_request_size - req->length))
+ n = dpy->max_request_size - req->length;
+ SetReqLen(req, n, n);
+ nbytes = ((long)n) << 2; /* watch out for macros... */
+ if (xoff || yoff) {
+ pt.x = xoff + points->x;
+ pt.y = yoff + points->y;
+ Data16 (dpy, (short *) &pt, 4);
+ if (nbytes > 4) {
+ Data16 (dpy, (short *) (points + 1), nbytes - 4);
+ }
+ } else {
+ Data16 (dpy, (short *) points, nbytes);
+ }
+ n_points -= n;
+ if (n_points && (mode == CoordModePrevious)) {
+ register XPoint *pptr = points;
+ points += n;
+ while (pptr != points) {
+ xoff += pptr->x;
+ yoff += pptr->y;
+ pptr++;
+ }
+ } else
+ points += n;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/DrRect.c b/src/DrRect.c
new file mode 100644
index 00000000..0c3c48e4
--- /dev/null
+++ b/src/DrRect.c
@@ -0,0 +1,95 @@
+/* $Xorg: DrRect.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+/* precompute the maximum size of batching request allowed */
+
+#define wsize (SIZEOF(xPolyRectangleReq) + WRCTSPERBATCH * SIZEOF(xRectangle))
+#define zsize (SIZEOF(xPolyRectangleReq) + ZRCTSPERBATCH * SIZEOF(xRectangle))
+
+XDrawRectangle(dpy, d, gc, x, y, width, height)
+ register Display *dpy;
+ Drawable d;
+ GC gc;
+ int x, y; /* INT16 */
+ unsigned int width, height; /* CARD16 */
+{
+ xRectangle *rect;
+#ifdef MUSTCOPY
+ xRectangle rectdata;
+ long len = SIZEOF(xRectangle);
+
+ rect = &rectdata;
+#endif /* MUSTCOPY */
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+
+ {
+ register xPolyRectangleReq *req = (xPolyRectangleReq *) dpy->last_req;
+
+ /* if same as previous request, with same drawable, batch requests */
+ if (
+ (req->reqType == X_PolyRectangle)
+ && (req->drawable == d)
+ && (req->gc == gc->gid)
+ && ((dpy->bufptr + SIZEOF(xRectangle)) <= dpy->bufmax)
+ && (((char *)dpy->bufptr - (char *)req) < (gc->values.line_width ?
+ wsize : zsize)) ) {
+ req->length += SIZEOF(xRectangle) >> 2;
+#ifndef MUSTCOPY
+ rect = (xRectangle *) dpy->bufptr;
+ dpy->bufptr += SIZEOF(xRectangle);
+#endif /* not MUSTCOPY */
+ }
+
+ else {
+ GetReqExtra(PolyRectangle, SIZEOF(xRectangle), req);
+ req->drawable = d;
+ req->gc = gc->gid;
+#ifdef MUSTCOPY
+ dpy->bufptr -= SIZEOF(xRectangle);
+#else
+ rect = (xRectangle *) NEXTPTR(req,xPolyRectangleReq);
+#endif /* MUSTCOPY */
+ }
+
+ rect->x = x;
+ rect->y = y;
+ rect->width = width;
+ rect->height = height;
+
+#ifdef MUSTCOPY
+ Data (dpy, (char *) rect, len); /* subtracted bufptr up above */
+#endif /* MUSTCOPY */
+
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/DrRects.c b/src/DrRects.c
new file mode 100644
index 00000000..ac87bd9b
--- /dev/null
+++ b/src/DrRects.c
@@ -0,0 +1,62 @@
+/* $Xorg: DrRects.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XDrawRectangles(dpy, d, gc, rects, n_rects)
+register Display *dpy;
+Drawable d;
+GC gc;
+XRectangle *rects;
+int n_rects;
+{
+ register xPolyRectangleReq *req;
+ long len;
+ int n;
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+ while (n_rects) {
+ GetReq(PolyRectangle, req);
+ req->drawable = d;
+ req->gc = gc->gid;
+ n = n_rects;
+ len = ((long)n) << 1;
+ if (!dpy->bigreq_size && len > (dpy->max_request_size - req->length)) {
+ n = (dpy->max_request_size - req->length) >> 1;
+ len = ((long)n) << 1;
+ }
+ SetReqLen(req, len, len);
+ len <<= 2; /* watch out for macros... */
+ Data16 (dpy, (short *) rects, len);
+ n_rects -= n;
+ rects += n;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/DrSegs.c b/src/DrSegs.c
new file mode 100644
index 00000000..41c4ea4a
--- /dev/null
+++ b/src/DrSegs.c
@@ -0,0 +1,63 @@
+/* $Xorg: DrSegs.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XDrawSegments (dpy, d, gc, segments, nsegments)
+ register Display *dpy;
+ Drawable d;
+ GC gc;
+ XSegment *segments;
+ int nsegments;
+{
+ register xPolySegmentReq *req;
+ long len;
+ int n;
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+ while (nsegments) {
+ GetReq (PolySegment, req);
+ req->drawable = d;
+ req->gc = gc->gid;
+ n = nsegments;
+ len = ((long)n) << 1;
+ if (!dpy->bigreq_size && len > (dpy->max_request_size - req->length)) {
+ n = (dpy->max_request_size - req->length) >> 1;
+ len = ((long)n) << 1;
+ }
+ SetReqLen(req, len, len);
+ len <<= 2; /* watch out for macros... */
+ Data16 (dpy, (short *) segments, len);
+ nsegments -= n;
+ segments += n;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/ErrDes.c b/src/ErrDes.c
new file mode 100644
index 00000000..a7f82cc7
--- /dev/null
+++ b/src/ErrDes.c
@@ -0,0 +1,196 @@
+/*
+ * $Xorg: ErrDes.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $
+ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#include "Xlibint.h"
+#include <X11/Xos.h>
+#include "Xresource.h"
+#include <stdio.h>
+
+#ifndef ERRORDB
+#define ERRORDB "/usr/lib/X11/XErrorDB"
+#endif
+
+#ifdef __STDC__
+#define Const const
+#else
+#define Const /**/
+#endif
+
+/*
+ * descriptions of errors in Section 4 of Protocol doc (pp. 350-351); more
+ * verbose descriptions are given in the error database
+ */
+static Const char * Const _XErrorList[] = {
+ /* No error */ "no error",
+ /* BadRequest */ "BadRequest",
+ /* BadValue */ "BadValue",
+ /* BadWindow */ "BadWindow",
+ /* BadPixmap */ "BadPixmap",
+ /* BadAtom */ "BadAtom",
+ /* BadCursor */ "BadCursor",
+ /* BadFont */ "BadFont",
+ /* BadMatch */ "BadMatch",
+ /* BadDrawable */ "BadDrawable",
+ /* BadAccess */ "BadAccess",
+ /* BadAlloc */ "BadAlloc",
+ /* BadColor */ "BadColor",
+ /* BadGC */ "BadGC",
+ /* BadIDChoice */ "BadIDChoice",
+ /* BadName */ "BadName",
+ /* BadLength */ "BadLength",
+ /* BadImplementation */ "BadImplementation",
+};
+
+
+XGetErrorText(dpy, code, buffer, nbytes)
+ register int code;
+ register Display *dpy;
+ char *buffer;
+ int nbytes;
+{
+ char buf[150];
+ register _XExtension *ext;
+ _XExtension *bext = (_XExtension *)NULL;
+
+ if (nbytes == 0) return 0;
+ if (code <= BadImplementation && code > 0) {
+ sprintf(buf, "%d", code);
+ (void) XGetErrorDatabaseText(dpy, "XProtoError", buf, _XErrorList[code],
+ buffer, nbytes);
+ } else
+ buffer[0] = '\0';
+ /* call out to any extensions interested */
+ for (ext = dpy->ext_procs; ext; ext = ext->next) {
+ if (ext->error_string)
+ (*ext->error_string)(dpy, code, &ext->codes, buffer, nbytes);
+ if (ext->codes.first_error &&
+ ext->codes.first_error < code &&
+ (!bext || ext->codes.first_error > bext->codes.first_error))
+ bext = ext;
+ }
+ if (!buffer[0] && bext) {
+ sprintf(buf, "%s.%d", bext->name, code - bext->codes.first_error);
+ (void) XGetErrorDatabaseText(dpy, "XProtoError", buf, "", buffer, nbytes);
+ }
+ if (!buffer[0])
+ sprintf(buffer, "%d", code);
+ return 0;
+}
+
+#if NeedFunctionPrototypes
+/*ARGSUSED*/
+XGetErrorDatabaseText(
+ Display *dpy,
+ register _Xconst char *name,
+ register _Xconst char *type,
+ _Xconst char *defaultp,
+ char *buffer,
+ int nbytes)
+#else
+/*ARGSUSED*/
+XGetErrorDatabaseText(dpy, name, type, defaultp, buffer, nbytes)
+ Display *dpy;
+ register char *name, *type;
+ char *defaultp;
+ char *buffer;
+ int nbytes;
+#endif
+{
+
+ static XrmDatabase db = NULL;
+ XrmString type_str;
+ XrmValue result;
+ char temp[BUFSIZ];
+ char* tptr;
+ unsigned long tlen;
+
+ if (nbytes == 0) return 0;
+
+ if (!db) {
+ /* the Xrm routines expect to be called with the global
+ mutex unlocked. */
+ XrmDatabase temp_db;
+ int do_destroy;
+
+ XrmInitialize();
+ temp_db = XrmGetFileDatabase(ERRORDB);
+
+ _XLockMutex(_Xglobal_lock);
+ if (!db) {
+ db = temp_db;
+ do_destroy = 0;
+ } else
+ do_destroy = 1; /* we didn't need to get it after all */
+ _XUnlockMutex(_Xglobal_lock);
+
+ if (do_destroy)
+ XrmDestroyDatabase(temp_db);
+ }
+
+ if (db)
+ {
+ tlen = strlen (name) + strlen (type) + 2;
+ if (tlen <= BUFSIZE) tptr = temp;
+ else tptr = Xmalloc (tlen);
+ sprintf(tptr, "%s.%s", name, type);
+ XrmGetResource(db, tptr, "ErrorType.ErrorNumber", &type_str, &result);
+ if (tptr != temp) Xfree (tptr);
+ }
+ else
+ result.addr = (XPointer)NULL;
+ if (!result.addr) {
+ result.addr = (XPointer) defaultp;
+ result.size = strlen(defaultp) + 1;
+ }
+ (void) strncpy (buffer, (char *) result.addr, nbytes);
+ if (result.size > nbytes) buffer[nbytes-1] = '\0';
+ return 0;
+}
diff --git a/src/ErrHndlr.c b/src/ErrHndlr.c
new file mode 100644
index 00000000..b7f6418b
--- /dev/null
+++ b/src/ErrHndlr.c
@@ -0,0 +1,95 @@
+/* $Xorg: ErrHndlr.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+extern int _XDefaultError();
+extern int _XDefaultIOError();
+/*
+ * XErrorHandler - This procedure sets the X non-fatal error handler
+ * (_XErrorFunction) to be the specified routine. If NULL is passed in
+ * the original error handler is restored.
+ */
+
+#if NeedFunctionPrototypes
+XErrorHandler XSetErrorHandler(XErrorHandler handler)
+#else
+XErrorHandler XSetErrorHandler(handler)
+ register XErrorHandler handler;
+#endif
+{
+ int (*oldhandler)();
+
+ _XLockMutex(_Xglobal_lock);
+ oldhandler = _XErrorFunction;
+
+ if (!oldhandler)
+ oldhandler = _XDefaultError;
+
+ if (handler != NULL) {
+ _XErrorFunction = handler;
+ }
+ else {
+ _XErrorFunction = _XDefaultError;
+ }
+ _XUnlockMutex(_Xglobal_lock);
+
+ return (XErrorHandler) oldhandler;
+}
+
+/*
+ * XIOErrorHandler - This procedure 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.
+ */
+
+extern int _XIOError();
+#if NeedFunctionPrototypes
+XIOErrorHandler XSetIOErrorHandler(XIOErrorHandler handler)
+#else
+XIOErrorHandler XSetIOErrorHandler(handler)
+ register XIOErrorHandler handler;
+#endif
+{
+ int (*oldhandler)();
+
+ _XLockMutex(_Xglobal_lock);
+ oldhandler = _XIOErrorFunction;
+
+ if (!oldhandler)
+ oldhandler = _XDefaultIOError;
+
+ if (handler != NULL) {
+ _XIOErrorFunction = handler;
+ }
+ else {
+ _XIOErrorFunction = _XDefaultIOError;
+ }
+ _XUnlockMutex(_Xglobal_lock);
+
+ return (XIOErrorHandler) oldhandler;
+}
diff --git a/src/EvToWire.c b/src/EvToWire.c
new file mode 100644
index 00000000..361c4e2c
--- /dev/null
+++ b/src/EvToWire.c
@@ -0,0 +1,404 @@
+/* $Xorg: EvToWire.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+
+/*
+
+Copyright 1985, 1986, 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+/*
+ * XEvToWire.c - Internal support routines for the C subroutine
+ * interface library (Xlib) to the X Window System Protocol V11.0.
+ */
+#define NEED_EVENTS
+#define NEED_REPLIES
+
+#include "Xlibint.h"
+
+/*
+ * reformat a wire event into an XEvent structure of the right type.
+ */
+Status
+_XEventToWire(dpy, re, event)
+register Display *dpy; /* pointer to display structure */
+register XEvent *re; /* pointer to where event should be reformatted */
+register xEvent *event; /* wire protocol event */
+{
+ switch (event->u.u.type = re->type) {
+ case KeyPress:
+ case KeyRelease:
+ {
+ register XKeyEvent *ev = (XKeyEvent*) re;
+ event->u.keyButtonPointer.root = ev->root;
+ event->u.keyButtonPointer.event = ev->window;
+ event->u.keyButtonPointer.child = ev->subwindow;
+ event->u.keyButtonPointer.time = ev->time;
+ event->u.keyButtonPointer.eventX = ev->x ;
+ event->u.keyButtonPointer.eventY = ev->y ;
+ event->u.keyButtonPointer.rootX = ev->x_root;
+ event->u.keyButtonPointer.rootY = ev->y_root;
+ event->u.keyButtonPointer.state = ev->state;
+ event->u.keyButtonPointer.sameScreen = ev->same_screen;
+ event->u.u.detail = ev->keycode;
+ }
+ break;
+ case ButtonPress:
+ case ButtonRelease:
+ {
+ register XButtonEvent *ev = (XButtonEvent *) re;
+ event->u.keyButtonPointer.root = ev->root;
+ event->u.keyButtonPointer.event = ev->window;
+ event->u.keyButtonPointer.child = ev->subwindow;
+ event->u.keyButtonPointer.time = ev->time;
+ event->u.keyButtonPointer.eventX = ev->x;
+ event->u.keyButtonPointer.eventY = ev->y;
+ event->u.keyButtonPointer.rootX = ev->x_root;
+ event->u.keyButtonPointer.rootY = ev->y_root;
+ event->u.keyButtonPointer.state = ev->state;
+ event->u.keyButtonPointer.sameScreen = ev->same_screen;
+ event->u.u.detail = ev->button;
+ }
+ break;
+ case MotionNotify:
+ {
+ register XMotionEvent *ev = (XMotionEvent *)re;
+ event->u.keyButtonPointer.root = ev->root;
+ event->u.keyButtonPointer.event = ev->window;
+ event->u.keyButtonPointer.child = ev->subwindow;
+ event->u.keyButtonPointer.time = ev->time;
+ event->u.keyButtonPointer.eventX= ev->x;
+ event->u.keyButtonPointer.eventY= ev->y;
+ event->u.keyButtonPointer.rootX = ev->x_root;
+ event->u.keyButtonPointer.rootY = ev->y_root;
+ event->u.keyButtonPointer.state = ev->state;
+ event->u.keyButtonPointer.sameScreen= ev->same_screen;
+ event->u.u.detail = ev->is_hint;
+ }
+ break;
+ case EnterNotify:
+ case LeaveNotify:
+ {
+ register XCrossingEvent *ev = (XCrossingEvent *) re;
+ event->u.enterLeave.root = ev->root;
+ event->u.enterLeave.event = ev->window;
+ event->u.enterLeave.child = ev->subwindow;
+ event->u.enterLeave.time = ev->time;
+ event->u.enterLeave.eventX = ev->x;
+ event->u.enterLeave.eventY = ev->y;
+ event->u.enterLeave.rootX = ev->x_root;
+ event->u.enterLeave.rootY = ev->y_root;
+ event->u.enterLeave.state = ev->state;
+ event->u.enterLeave.mode = ev->mode;
+ event->u.enterLeave.flags = 0;
+ if (ev->same_screen) {
+ event->u.enterLeave.flags |= ELFlagSameScreen;
+ }
+ if (ev->focus) {
+ event->u.enterLeave.flags |= ELFlagFocus;
+ }
+ event->u.u.detail = ev->detail;
+ }
+ break;
+ case FocusIn:
+ case FocusOut:
+ {
+ register XFocusChangeEvent *ev = (XFocusChangeEvent *) re;
+ event->u.focus.window = ev->window;
+ event->u.focus.mode = ev->mode;
+ event->u.u.detail = ev->detail;
+ }
+ break;
+ case KeymapNotify:
+ {
+ register XKeymapEvent *ev = (XKeymapEvent *) re;
+ memcpy ((char *)(((xKeymapEvent *) event)->map),
+ &ev->key_vector[1],
+ sizeof (((xKeymapEvent *) event)->map));
+ }
+ break;
+ case Expose:
+ {
+ register XExposeEvent *ev = (XExposeEvent *) re;
+ event->u.expose.window = ev->window;
+ event->u.expose.x = ev->x;
+ event->u.expose.y = ev->y;
+ event->u.expose.width = ev->width;
+ event->u.expose.height = ev->height;
+ event->u.expose.count = ev->count;
+ }
+ break;
+ case GraphicsExpose:
+ {
+ register XGraphicsExposeEvent *ev =
+ (XGraphicsExposeEvent *) re;
+ event->u.graphicsExposure.drawable = ev->drawable;
+ event->u.graphicsExposure.x = ev->x;
+ event->u.graphicsExposure.y = ev->y;
+ event->u.graphicsExposure.width = ev->width;
+ event->u.graphicsExposure.height = ev->height;
+ event->u.graphicsExposure.count = ev->count;
+ event->u.graphicsExposure.majorEvent= ev->major_code;
+ event->u.graphicsExposure.minorEvent= ev->minor_code;
+ }
+ break;
+ case NoExpose:
+ {
+ register XNoExposeEvent *ev = (XNoExposeEvent *) re;
+ event->u.noExposure.drawable = ev->drawable;
+ event->u.noExposure.majorEvent = ev->major_code;
+ event->u.noExposure.minorEvent = ev->minor_code;
+ }
+ break;
+ case VisibilityNotify:
+ {
+ register XVisibilityEvent *ev = (XVisibilityEvent *) re;
+ event->u.visibility.window = ev->window;
+ event->u.visibility.state = ev->state;
+ }
+ break;
+ case CreateNotify:
+ {
+ register XCreateWindowEvent *ev =
+ (XCreateWindowEvent *) re;
+ event->u.createNotify.window = ev->window;
+ event->u.createNotify.parent = ev->parent;
+ event->u.createNotify.x = ev->x;
+ event->u.createNotify.y = ev->y;
+ event->u.createNotify.width = ev->width;
+ event->u.createNotify.height = ev->height;
+ event->u.createNotify.borderWidth = ev->border_width;
+ event->u.createNotify.override = ev->override_redirect;
+ }
+ break;
+ case DestroyNotify:
+ {
+ register XDestroyWindowEvent *ev =
+ (XDestroyWindowEvent *) re;
+ event->u.destroyNotify.window = ev->window;
+ event->u.destroyNotify.event = ev->event;
+ }
+ break;
+ case UnmapNotify:
+ {
+ register XUnmapEvent *ev = (XUnmapEvent *) re;
+ event->u.unmapNotify.window = ev->window;
+ event->u.unmapNotify.event = ev->event;
+ event->u.unmapNotify.fromConfigure = ev->from_configure;
+ }
+ break;
+ case MapNotify:
+ {
+ register XMapEvent *ev = (XMapEvent *) re;
+ event->u.mapNotify.window = ev->window;
+ event->u.mapNotify.event = ev->event;
+ event->u.mapNotify.override = ev->override_redirect;
+ }
+ break;
+ case MapRequest:
+ {
+ register XMapRequestEvent *ev = (XMapRequestEvent *) re;
+ event->u.mapRequest.window = ev->window;
+ event->u.mapRequest.parent = ev->parent;
+ }
+ break;
+ case ReparentNotify:
+ {
+ register XReparentEvent *ev = (XReparentEvent *) re;
+ event->u.reparent.window = ev->window;
+ event->u.reparent.event = ev->event;
+ event->u.reparent.parent = ev->parent;
+ event->u.reparent.x = ev->x;
+ event->u.reparent.y = ev->y;
+ event->u.reparent.override = ev->override_redirect;
+ }
+ break;
+ case ConfigureNotify:
+ {
+ register XConfigureEvent *ev = (XConfigureEvent *) re;
+ event->u.configureNotify.window = ev->window;
+ event->u.configureNotify.event = ev->event;
+ event->u.configureNotify.aboveSibling = ev->above;
+ event->u.configureNotify.x = ev->x;
+ event->u.configureNotify.y = ev->y;
+ event->u.configureNotify.width = ev->width;
+ event->u.configureNotify.height = ev->height;
+ event->u.configureNotify.borderWidth= ev->border_width;
+ event->u.configureNotify.override = ev->override_redirect;
+ }
+ break;
+ case ConfigureRequest:
+ {
+ register XConfigureRequestEvent *ev =
+ (XConfigureRequestEvent *) re;
+ event->u.configureRequest.window = ev->window;
+ event->u.configureRequest.parent = ev->parent;
+ event->u.configureRequest.sibling = ev->above;
+ event->u.configureRequest.x = ev->x;
+ event->u.configureRequest.y = ev->y;
+ event->u.configureRequest.width = ev->width;
+ event->u.configureRequest.height = ev->height;
+ event->u.configureRequest.borderWidth= ev->border_width;
+ event->u.configureRequest.valueMask= ev->value_mask;
+ event->u.u.detail = ev->detail;
+ }
+ break;
+ case GravityNotify:
+ {
+ register XGravityEvent *ev = (XGravityEvent *) re;
+ event->u.gravity.window = ev->window;
+ event->u.gravity.event = ev->event;
+ event->u.gravity.x = ev->x;
+ event->u.gravity.y = ev->y;
+ }
+ break;
+ case ResizeRequest:
+ {
+ register XResizeRequestEvent *ev =
+ (XResizeRequestEvent *) re;
+ event->u.resizeRequest.window = ev->window;
+ event->u.resizeRequest.width = ev->width;
+ event->u.resizeRequest.height = ev->height;
+ }
+ break;
+ case CirculateNotify:
+ {
+ register XCirculateEvent *ev = (XCirculateEvent *) re;
+ event->u.circulate.window = ev->window;
+ event->u.circulate.event = ev->event;
+ event->u.circulate.place = ev->place;
+ }
+ break;
+ case CirculateRequest:
+ {
+ register XCirculateRequestEvent *ev =
+ (XCirculateRequestEvent *) re;
+ event->u.circulate.window = ev->window;
+ event->u.circulate.event = ev->parent;
+ event->u.circulate.place = ev->place;
+ }
+ break;
+ case PropertyNotify:
+ {
+ register XPropertyEvent *ev = (XPropertyEvent *) re;
+ event->u.property.window = ev->window;
+ event->u.property.atom = ev->atom;
+ event->u.property.time = ev->time;
+ event->u.property.state = ev->state;
+ }
+ break;
+ case SelectionClear:
+ {
+ register XSelectionClearEvent *ev =
+ (XSelectionClearEvent *) re;
+ event->u.selectionClear.window = ev->window;
+ event->u.selectionClear.atom = ev->selection;
+ event->u.selectionClear.time = ev->time;
+ }
+ break;
+ case SelectionRequest:
+ {
+ register XSelectionRequestEvent *ev =
+ (XSelectionRequestEvent *) re;
+ event->u.selectionRequest.owner = ev->owner;
+ event->u.selectionRequest.requestor = ev->requestor;
+ event->u.selectionRequest.selection = ev->selection;
+ event->u.selectionRequest.target = ev->target;
+ event->u.selectionRequest.property = ev->property;
+ event->u.selectionRequest.time = ev->time;
+ }
+ break;
+ case SelectionNotify:
+ {
+ register XSelectionEvent *ev = (XSelectionEvent *) re;
+ event->u.selectionNotify.requestor = ev->requestor;
+ event->u.selectionNotify.selection = ev->selection;
+ event->u.selectionNotify.target = ev->target;
+ event->u.selectionNotify.property = ev->property;
+ event->u.selectionNotify.time = ev->time;
+ }
+ break;
+ case ColormapNotify:
+ {
+ register XColormapEvent *ev = (XColormapEvent *) re;
+ event->u.colormap.window = ev->window;
+ event->u.colormap.colormap = ev->colormap;
+ event->u.colormap.new = ev->new;
+ event->u.colormap.state = ev->state;
+ }
+ break;
+ case ClientMessage:
+ {
+ register int i;
+ register XClientMessageEvent *ev
+ = (XClientMessageEvent *) re;
+ event->u.clientMessage.window = ev->window;
+ event->u.u.detail = ev->format;
+ switch (ev->format) {
+ case 8:
+ event->u.clientMessage.u.b.type = ev->message_type;
+ for (i = 0; i < 20; i++)
+ event->u.clientMessage.u.b.bytes[i] = ev->data.b[i];
+ break;
+ case 16:
+ event->u.clientMessage.u.s.type = ev->message_type;
+ event->u.clientMessage.u.s.shorts0 = ev->data.s[0];
+ event->u.clientMessage.u.s.shorts1 = ev->data.s[1];
+ event->u.clientMessage.u.s.shorts2 = ev->data.s[2];
+ event->u.clientMessage.u.s.shorts3 = ev->data.s[3];
+ event->u.clientMessage.u.s.shorts4 = ev->data.s[4];
+ event->u.clientMessage.u.s.shorts5 = ev->data.s[5];
+ event->u.clientMessage.u.s.shorts6 = ev->data.s[6];
+ event->u.clientMessage.u.s.shorts7 = ev->data.s[7];
+ event->u.clientMessage.u.s.shorts8 = ev->data.s[8];
+ event->u.clientMessage.u.s.shorts9 = ev->data.s[9];
+ break;
+ case 32:
+ event->u.clientMessage.u.l.type = ev->message_type;
+ event->u.clientMessage.u.l.longs0 = ev->data.l[0];
+ event->u.clientMessage.u.l.longs1 = ev->data.l[1];
+ event->u.clientMessage.u.l.longs2 = ev->data.l[2];
+ event->u.clientMessage.u.l.longs3 = ev->data.l[3];
+ event->u.clientMessage.u.l.longs4 = ev->data.l[4];
+ break;
+ default:
+ /* client passing bogus data, let server complain */
+ break;
+ }
+ }
+ break;
+ case MappingNotify:
+ {
+ register XMappingEvent *ev = (XMappingEvent *) re;
+ event->u.mappingNotify.firstKeyCode = ev->first_keycode;
+ event->u.mappingNotify.request = ev->request;
+ event->u.mappingNotify.count = ev->count;
+ }
+ break;
+
+ default:
+ return(_XUnknownNativeEvent(dpy, re, event));
+ }
+ return(1);
+}
diff --git a/src/FSSaver.c b/src/FSSaver.c
new file mode 100644
index 00000000..57cde1aa
--- /dev/null
+++ b/src/FSSaver.c
@@ -0,0 +1,60 @@
+/* $Xorg: FSSaver.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XActivateScreenSaver(dpy)
+ register Display *dpy;
+
+{
+ XForceScreenSaver (dpy, ScreenSaverActive);
+ return 1;
+}
+
+XResetScreenSaver(dpy)
+ register Display *dpy;
+
+{
+ XForceScreenSaver (dpy, ScreenSaverReset);
+ return 1;
+}
+
+XForceScreenSaver(dpy, mode)
+ register Display *dpy;
+ int mode;
+
+{
+ register xForceScreenSaverReq *req;
+
+ LockDisplay(dpy);
+ GetReq(ForceScreenSaver, req);
+ req->mode = mode;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/FSWrap.c b/src/FSWrap.c
new file mode 100644
index 00000000..14adca02
--- /dev/null
+++ b/src/FSWrap.c
@@ -0,0 +1,273 @@
+/* $Xorg: FSWrap.c,v 1.5 2001/02/09 02:03:32 xorgcvs Exp $ */
+
+/*
+ * Copyright 1991 by the Open Software Foundation
+ * Copyright 1993 by the TOSHIBA Corp.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name Open Software Foundation
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. Open Software
+ * Foundation makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * OPEN SOFTWARE FOUNDATION DISCLAIMS ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL OPEN SOFTWARE FOUNDATIONN BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * M. Collins OSF
+ *
+ * Katsuhisa Yano TOSHIBA Corp.
+ */
+
+/*
+
+Copyright 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include <ctype.h>
+#include <X11/Xos.h>
+
+
+#define XMAXLIST 256
+
+char **
+_XParseBaseFontNameList(str, num)
+ char *str;
+ int *num;
+{
+ char *plist[XMAXLIST];
+ char **list;
+ char *ptr;
+
+ *num = 0;
+ if (!str || !*str) {
+ return (char **)NULL;
+ }
+ while (*str && isspace(*str))
+ str++;
+ if (!*str)
+ return (char **)NULL;
+
+ if (!(ptr = Xmalloc((unsigned)strlen(str) + 1))) {
+ return (char **)NULL;
+ }
+ strcpy(ptr, str);
+
+ /* somebody who specifies more than XMAXLIST basefontnames will lose */
+ while (*num < (sizeof plist / sizeof plist[0])) {
+ char *back;
+
+ plist[*num] = ptr;
+ if ((ptr = strchr(ptr, ','))) {
+ back = ptr;
+ } else {
+ back = plist[*num] + strlen(plist[*num]);
+ }
+ while (isspace(*(back - 1)))
+ back--;
+ *back = '\0';
+ (*num)++;
+ if (!ptr)
+ break;
+ ptr++;
+ while (*ptr && isspace(*ptr))
+ ptr++;
+ if (!*ptr)
+ break;
+ }
+ if (!(list = (char **) Xmalloc((unsigned)sizeof(char *) * (*num + 1)))) {
+ Xfree(ptr);
+ return (char **)NULL;
+ }
+ memcpy((char *)list, (char *)plist, sizeof(char *) * (*num));
+ *(list + *num) = NULL;
+
+ return list;
+}
+
+static char **
+copy_string_list(string_list, list_count)
+ char **string_list;
+ int list_count;
+{
+ char **string_list_ret, **list_src, **list_dst, *dst;
+ int length, count;
+
+ if (string_list == NULL)
+ return (char **) NULL;
+
+ string_list_ret = (char **) Xmalloc(sizeof(char *) * list_count);
+ if (string_list_ret == NULL)
+ return (char **) NULL;
+
+ list_src = string_list;
+ count = list_count;
+ for (length = 0; count-- > 0; list_src++)
+ length += strlen(*list_src) + 1;
+
+ dst = (char *) Xmalloc(length);
+ if (dst == NULL) {
+ Xfree(string_list_ret);
+ return (char **) NULL;
+ }
+
+ list_src = string_list;
+ count = list_count;
+ list_dst = string_list_ret;
+ for ( ; count-- > 0; list_src++) {
+ strcpy(dst, *list_src);
+ *list_dst++ = dst;
+ dst += strlen(dst) + 1;
+ }
+
+ return string_list_ret;
+}
+
+#if NeedFunctionPrototypes
+XFontSet
+XCreateFontSet (
+ Display *dpy,
+ _Xconst char *base_font_name_list,
+ char ***missing_charset_list,
+ int *missing_charset_count,
+ char **def_string)
+#else
+XFontSet
+XCreateFontSet (dpy, base_font_name_list, missing_charset_list,
+ missing_charset_count, def_string)
+ Display *dpy;
+ char *base_font_name_list;
+ char ***missing_charset_list;
+ int *missing_charset_count;
+ char **def_string;
+#endif
+{
+ XOM om;
+ XOC oc;
+ XOMCharSetList *list;
+
+ *missing_charset_list = NULL;
+ *missing_charset_count = 0;
+
+ om = XOpenOM(dpy, NULL, NULL, NULL);
+ if (om == NULL)
+ return (XFontSet) NULL;
+
+ if ((oc = XCreateOC(om, XNBaseFontName, base_font_name_list, NULL))) {
+ list = &oc->core.missing_list;
+ oc->core.om_automatic = True;
+ } else
+ list = &om->core.required_charset;
+
+ *missing_charset_list = copy_string_list(list->charset_list,
+ list->charset_count);
+ *missing_charset_count = list->charset_count;
+
+ if (list->charset_list && *missing_charset_list == NULL)
+ oc = NULL;
+
+ if (oc && def_string) {
+ *def_string = oc->core.default_string;
+ if (!*def_string)
+ *def_string = "";
+ }
+
+ if (oc == NULL)
+ XCloseOM(om);
+
+ return (XFontSet) oc;
+}
+
+int
+XFontsOfFontSet(font_set, font_struct_list, font_name_list)
+ XFontSet font_set;
+ XFontStruct ***font_struct_list;
+ char ***font_name_list;
+{
+ *font_name_list = font_set->core.font_info.font_name_list;
+ *font_struct_list = font_set->core.font_info.font_struct_list;
+ return font_set->core.font_info.num_font;
+}
+
+char *
+XBaseFontNameListOfFontSet(font_set)
+ XFontSet font_set;
+{
+ return font_set->core.base_name_list;
+}
+
+char *
+XLocaleOfFontSet(font_set)
+ XFontSet font_set;
+{
+ return font_set->core.om->core.lcd->core->name;
+}
+
+extern Bool XContextDependentDrawing(font_set)
+ XFontSet font_set;
+{
+ return font_set->core.om->core.context_dependent;
+}
+
+Bool
+XDirectionalDependentDrawing(font_set)
+ XFontSet font_set;
+{
+ return font_set->core.om->core.directional_dependent;
+}
+
+Bool
+XContextualDrawing(font_set)
+ XFontSet font_set;
+{
+ return font_set->core.om->core.contextual_drawing;
+}
+
+XFontSetExtents *
+XExtentsOfFontSet(font_set)
+ XFontSet font_set;
+{
+ return &font_set->core.font_set_extents;
+}
+
+void
+XFreeFontSet(dpy, font_set)
+ Display *dpy;
+ XFontSet font_set;
+{
+ XCloseOM(font_set->core.om);
+}
diff --git a/src/FetchName.c b/src/FetchName.c
new file mode 100644
index 00000000..1317fa86
--- /dev/null
+++ b/src/FetchName.c
@@ -0,0 +1,93 @@
+/* $Xorg: FetchName.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include <X11/Xlibint.h>
+#include <X11/Xatom.h>
+#include <X11/Xos.h>
+#include <stdio.h>
+
+
+Status XFetchName (dpy, w, name)
+ register Display *dpy;
+ Window w;
+ char **name;
+{
+ Atom actual_type;
+ int actual_format;
+ unsigned long nitems;
+ unsigned long leftover;
+ unsigned char *data = NULL;
+ if (XGetWindowProperty(dpy, w, XA_WM_NAME, 0L, (long)BUFSIZ, False, XA_STRING,
+ &actual_type,
+ &actual_format, &nitems, &leftover, &data) != Success) {
+ *name = NULL;
+ return (0);
+ }
+ if ( (actual_type == XA_STRING) && (actual_format == 8) ) {
+
+ /* The data returned by XGetWindowProperty is guarranteed to
+ contain one extra byte that is null terminated to make retrieveing
+ string properties easy. */
+
+ *name = (char *)data;
+ return(1);
+ }
+ if (data) Xfree ((char *)data);
+ *name = NULL;
+ return(0);
+}
+
+Status XGetIconName (dpy, w, icon_name)
+ register Display *dpy;
+ Window w;
+ char **icon_name;
+{
+ Atom actual_type;
+ int actual_format;
+ unsigned long nitems;
+ unsigned long leftover;
+ unsigned char *data = NULL;
+ if (XGetWindowProperty(dpy, w, XA_WM_ICON_NAME, 0L, (long)BUFSIZ, False,
+ XA_STRING,
+ &actual_type,
+ &actual_format, &nitems, &leftover, &data) != Success) {
+ *icon_name = NULL;
+ return (0);
+ }
+ if ( (actual_type == XA_STRING) && (actual_format == 8) ) {
+
+ /* The data returned by XGetWindowProperty is guarranteed to
+ contain one extra byte that is null terminated to make retrieveing
+ string properties easy. */
+
+ *icon_name = (char*)data;
+ return(1);
+ }
+ if (data) Xfree ((char *)data);
+ *icon_name = NULL;
+ return(0);
+}
diff --git a/src/FillArc.c b/src/FillArc.c
new file mode 100644
index 00000000..22e41910
--- /dev/null
+++ b/src/FillArc.c
@@ -0,0 +1,96 @@
+/* $Xorg: FillArc.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+/* precompute the maximum size of batching request allowed */
+
+#define size (SIZEOF(xPolyFillArcReq) + FARCSPERBATCH * SIZEOF(xArc))
+
+XFillArc(dpy, d, gc, x, y, width, height, angle1, angle2)
+ register Display *dpy;
+ Drawable d;
+ GC gc;
+ int x, y; /* INT16 */
+ unsigned int width, height; /* CARD16 */
+ int angle1, angle2; /* INT16 */
+{
+ xArc *arc;
+#ifdef MUSTCOPY
+ xArc arcdata;
+ long len = SIZEOF(xArc);
+
+ arc = &arcdata;
+#endif /* MUSTCOPY */
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+
+ {
+ register xPolyFillArcReq *req = (xPolyFillArcReq *) dpy->last_req;
+
+ /* if same as previous request, with same drawable, batch requests */
+ if (
+ (req->reqType == X_PolyFillArc)
+ && (req->drawable == d)
+ && (req->gc == gc->gid)
+ && ((dpy->bufptr + SIZEOF(xArc)) <= dpy->bufmax)
+ && (((char *)dpy->bufptr - (char *)req) < size) ) {
+ req->length += SIZEOF(xArc) >> 2;
+#ifndef MUSTCOPY
+ arc = (xArc *) dpy->bufptr;
+ dpy->bufptr += SIZEOF(xArc);
+#endif /* not MUSTCOPY */
+ }
+
+ else {
+ GetReqExtra(PolyFillArc, SIZEOF(xArc), req);
+
+ req->drawable = d;
+ req->gc = gc->gid;
+#ifdef MUSTCOPY
+ dpy->bufptr -= SIZEOF(xArc);
+#else
+ arc = (xArc *) NEXTPTR(req,xPolyFillArcReq);
+#endif /* MUSTCOPY */
+ }
+ arc->x = x;
+ arc->y = y;
+ arc->width = width;
+ arc->height = height;
+ arc->angle1 = angle1;
+ arc->angle2 = angle2;
+
+#ifdef MUSTCOPY
+ Data (dpy, (char *) arc, len);
+#endif /* MUSTCOPY */
+
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/FillArcs.c b/src/FillArcs.c
new file mode 100644
index 00000000..115f25cc
--- /dev/null
+++ b/src/FillArcs.c
@@ -0,0 +1,64 @@
+/* $Xorg: FillArcs.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+#define arc_scale (SIZEOF(xArc) / 4)
+
+XFillArcs(dpy, d, gc, arcs, n_arcs)
+register Display *dpy;
+Drawable d;
+GC gc;
+XArc *arcs;
+int n_arcs;
+{
+ register xPolyFillArcReq *req;
+ long len;
+ int n;
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+ while (n_arcs) {
+ GetReq(PolyFillArc, req);
+ req->drawable = d;
+ req->gc = gc->gid;
+ n = n_arcs;
+ len = ((long)n) * arc_scale;
+ if (!dpy->bigreq_size && len > (dpy->max_request_size - req->length)) {
+ n = (dpy->max_request_size - req->length) / arc_scale;
+ len = ((long)n) * arc_scale;
+ }
+ SetReqLen(req, len, len);
+ len <<= 2; /* watch out for macros... */
+ Data16 (dpy, (short *) arcs, len);
+ n_arcs -= n;
+ arcs += n;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/FillPoly.c b/src/FillPoly.c
new file mode 100644
index 00000000..c8f40c63
--- /dev/null
+++ b/src/FillPoly.c
@@ -0,0 +1,61 @@
+/* $Xorg: FillPoly.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XFillPolygon(dpy, d, gc, points, n_points, shape, mode)
+register Display *dpy;
+Drawable d;
+GC gc;
+XPoint *points;
+int n_points;
+int shape;
+int mode;
+{
+ register xFillPolyReq *req;
+ register long nbytes;
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+ GetReq(FillPoly, req);
+
+ req->drawable = d;
+ req->gc = gc->gid;
+ req->shape = shape;
+ req->coordMode = mode;
+
+ SetReqLen(req, n_points, 65535 - req->length);
+
+ /* shift (mult. by 4) before passing to the (possible) macro */
+
+ nbytes = n_points << 2;
+
+ Data16 (dpy, (short *) points, nbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/FillRct.c b/src/FillRct.c
new file mode 100644
index 00000000..d2537c7c
--- /dev/null
+++ b/src/FillRct.c
@@ -0,0 +1,92 @@
+/* $Xorg: FillRct.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+/* precompute the maximum size of batching request allowed */
+
+#define size (SIZEOF(xPolyFillRectangleReq) + FRCTSPERBATCH * SIZEOF(xRectangle))
+
+XFillRectangle(dpy, d, gc, x, y, width, height)
+ register Display *dpy;
+ Drawable d;
+ GC gc;
+ int x, y; /* INT16 */
+ unsigned int width, height; /* CARD16 */
+{
+ xRectangle *rect;
+#ifdef MUSTCOPY
+ xRectangle rectdata;
+ long len = SIZEOF(xRectangle);
+
+ rect = &rectdata;
+#endif /* MUSTCOPY */
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+
+ {
+ register xPolyFillRectangleReq *req
+ = (xPolyFillRectangleReq *) dpy->last_req;
+
+ /* if same as previous request, with same drawable, batch requests */
+ if (
+ (req->reqType == X_PolyFillRectangle)
+ && (req->drawable == d)
+ && (req->gc == gc->gid)
+ && ((dpy->bufptr + SIZEOF(xRectangle)) <= dpy->bufmax)
+ && (((char *)dpy->bufptr - (char *)req) < size) ) {
+ req->length += SIZEOF(xRectangle) >> 2;
+#ifndef MUSTCOPY
+ rect = (xRectangle *) dpy->bufptr;
+ dpy->bufptr += SIZEOF(xRectangle);
+#endif /* not MUSTCOPY */
+ }
+
+ else {
+ GetReqExtra(PolyFillRectangle, SIZEOF(xRectangle), req);
+ req->drawable = d;
+ req->gc = gc->gid;
+#ifdef MUSTCOPY
+ dpy->bufptr -= SIZEOF(xRectangle);
+#else
+ rect = (xRectangle *) NEXTPTR(req,xPolyFillRectangleReq);
+#endif /* MUSTCOPY */
+ }
+ rect->x = x;
+ rect->y = y;
+ rect->width = width;
+ rect->height = height;
+
+#ifdef MUSTCOPY
+ Data (dpy, (char *) rect, len);
+#endif /* MUSTCOPY */
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/FillRcts.c b/src/FillRcts.c
new file mode 100644
index 00000000..4e86fec3
--- /dev/null
+++ b/src/FillRcts.c
@@ -0,0 +1,63 @@
+/* $Xorg: FillRcts.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XFillRectangles(dpy, d, gc, rectangles, n_rects)
+register Display *dpy;
+Drawable d;
+GC gc;
+XRectangle *rectangles;
+int n_rects;
+{
+ register xPolyFillRectangleReq *req;
+ long len;
+ int n;
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+ while (n_rects) {
+ GetReq(PolyFillRectangle, req);
+ req->drawable = d;
+ req->gc = gc->gid;
+ n = n_rects;
+ len = ((long)n) << 1;
+ if (!dpy->bigreq_size && len > (dpy->max_request_size - req->length)) {
+ n = (dpy->max_request_size - req->length) >> 1;
+ len = ((long)n) << 1;
+ }
+ SetReqLen(req, len, len);
+ len <<= 2; /* watch out for macros... */
+ Data16 (dpy, (short *) rectangles, len);
+ n_rects -= n;
+ rectangles += n;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/FilterEv.c b/src/FilterEv.c
new file mode 100644
index 00000000..2b104839
--- /dev/null
+++ b/src/FilterEv.c
@@ -0,0 +1,104 @@
+/* $Xorg: FilterEv.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+
+ /*
+ * Copyright 1990, 1991 by OMRON Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name OMRON not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. OMRON makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * OMRON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL OMRON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Seiji Kuwari OMRON Corporation
+ * kuwa@omron.co.jp
+ * kuwa%omron.co.jp@uunet.uu.net
+ */
+
+/*
+
+Copyright 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include "Xlcint.h"
+
+#ifdef __STDC__
+#define Const const
+#else
+#define Const /**/
+#endif
+extern long Const _Xevent_to_mask[];
+
+/*
+ * Look up if there is a specified filter for the event.
+ */
+Bool
+XFilterEvent(ev, window)
+ XEvent *ev;
+ Window window;
+{
+ XFilterEventList p;
+ Window win;
+ long mask;
+ Bool ret;
+
+ if (window)
+ win = window;
+ else
+ win = ev->xany.window;
+ if (ev->type >= LASTEvent)
+ mask = 0;
+ else
+ mask = _Xevent_to_mask[ev->type];
+
+ LockDisplay(ev->xany.display);
+ for (p = ev->xany.display->im_filters; p != NULL; p = p->next) {
+ if (win == p->window) {
+ if ((mask & p->event_mask) ||
+ (ev->type >= p->start_type && ev->type <= p->end_type)) {
+ ret = (*(p->filter))(ev->xany.display, p->window, ev,
+ p->client_data);
+ UnlockDisplay(ev->xany.display);
+ return(ret);
+ }
+ }
+ }
+ UnlockDisplay(ev->xany.display);
+ return(False);
+}
diff --git a/src/Flush.c b/src/Flush.c
new file mode 100644
index 00000000..fd6b3935
--- /dev/null
+++ b/src/Flush.c
@@ -0,0 +1,40 @@
+/* $Xorg: Flush.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+/* Flush all buffered output requests. */
+/* NOTE: NOT necessary when calling any of the Xlib routines. */
+
+XFlush (dpy)
+ register Display *dpy;
+ {
+ LockDisplay(dpy);
+ _XFlush (dpy);
+ UnlockDisplay(dpy);
+ return 1;
+ }
diff --git a/src/Font.c b/src/Font.c
new file mode 100644
index 00000000..2b1eae84
--- /dev/null
+++ b/src/Font.c
@@ -0,0 +1,241 @@
+/* $Xorg: Font.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+static XFontStruct *_XQueryFont();
+
+#if NeedFunctionPrototypes
+XFontStruct *XLoadQueryFont(
+ register Display *dpy,
+ _Xconst char *name)
+#else
+XFontStruct *XLoadQueryFont(dpy, name)
+ register Display *dpy;
+ char *name;
+#endif
+{
+ XFontStruct *font_result;
+ register long nbytes;
+ Font fid;
+ xOpenFontReq *req;
+ unsigned long seq;
+
+ LockDisplay(dpy);
+ GetReq(OpenFont, req);
+ seq = dpy->request;
+ nbytes = req->nbytes = name ? strlen(name) : 0;
+ req->fid = fid = XAllocID(dpy);
+ req->length += (nbytes+3)>>2;
+ Data (dpy, name, nbytes);
+ font_result = _XQueryFont(dpy, fid, seq);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return font_result;
+}
+
+XFreeFont(dpy, fs)
+ register Display *dpy;
+ XFontStruct *fs;
+{
+ register xResourceReq *req;
+ register _XExtension *ext;
+
+ LockDisplay(dpy);
+ /* call out to any extensions interested */
+ for (ext = dpy->ext_procs; ext; ext = ext->next)
+ if (ext->free_Font) (*ext->free_Font)(dpy, fs, &ext->codes);
+ GetResReq (CloseFont, fs->fid, req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ _XFreeExtData(fs->ext_data);
+ if (fs->per_char)
+ Xfree ((char *) fs->per_char);
+ if (fs->properties)
+ Xfree ((char *) fs->properties);
+ Xfree ((char *) fs);
+ return 1;
+}
+
+static XFontStruct *
+_XQueryFont (dpy, fid, seq)
+ register Display *dpy;
+ Font fid;
+ unsigned long seq;
+{
+ register XFontStruct *fs;
+ register long nbytes;
+ xQueryFontReply reply;
+ register xResourceReq *req;
+ register _XExtension *ext;
+ _XAsyncHandler async;
+ _XAsyncErrorState async_state;
+
+ if (seq) {
+ async_state.min_sequence_number = seq;
+ async_state.max_sequence_number = seq;
+ async_state.error_code = BadName;
+ async_state.major_opcode = X_OpenFont;
+ async_state.minor_opcode = 0;
+ async_state.error_count = 0;
+ async.next = dpy->async_handlers;
+ async.handler = _XAsyncErrorHandler;
+ async.data = (XPointer)&async_state;
+ dpy->async_handlers = &async;
+ }
+ GetResReq(QueryFont, fid, req);
+ if (!_XReply (dpy, (xReply *) &reply,
+ ((SIZEOF(xQueryFontReply) - SIZEOF(xReply)) >> 2), xFalse)) {
+ if (seq)
+ DeqAsyncHandler(dpy, &async);
+ return (XFontStruct *)NULL;
+ }
+ if (seq)
+ DeqAsyncHandler(dpy, &async);
+ if (! (fs = (XFontStruct *) Xmalloc (sizeof (XFontStruct)))) {
+ _XEatData(dpy, (unsigned long)(reply.nFontProps * SIZEOF(xFontProp) +
+ reply.nCharInfos * SIZEOF(xCharInfo)));
+ return (XFontStruct *)NULL;
+ }
+ fs->ext_data = NULL;
+ fs->fid = fid;
+ fs->direction = reply.drawDirection;
+ fs->min_char_or_byte2 = reply.minCharOrByte2;
+ fs->max_char_or_byte2 = reply.maxCharOrByte2;
+ fs->min_byte1 = reply.minByte1;
+ fs->max_byte1 = reply.maxByte1;
+ fs->default_char = reply.defaultChar;
+ fs->all_chars_exist = reply.allCharsExist;
+ fs->ascent = cvtINT16toInt (reply.fontAscent);
+ fs->descent = cvtINT16toInt (reply.fontDescent);
+
+#ifdef MUSTCOPY
+ {
+ xCharInfo *xcip;
+
+ xcip = (xCharInfo *) &reply.minBounds;
+ fs->min_bounds.lbearing = cvtINT16toShort(xcip->leftSideBearing);
+ fs->min_bounds.rbearing = cvtINT16toShort(xcip->rightSideBearing);
+ fs->min_bounds.width = cvtINT16toShort(xcip->characterWidth);
+ fs->min_bounds.ascent = cvtINT16toShort(xcip->ascent);
+ fs->min_bounds.descent = cvtINT16toShort(xcip->descent);
+ fs->min_bounds.attributes = xcip->attributes;
+
+ xcip = (xCharInfo *) &reply.maxBounds;
+ fs->max_bounds.lbearing = cvtINT16toShort(xcip->leftSideBearing);
+ fs->max_bounds.rbearing = cvtINT16toShort(xcip->rightSideBearing);
+ fs->max_bounds.width = cvtINT16toShort(xcip->characterWidth);
+ fs->max_bounds.ascent = cvtINT16toShort(xcip->ascent);
+ fs->max_bounds.descent = cvtINT16toShort(xcip->descent);
+ fs->max_bounds.attributes = xcip->attributes;
+ }
+#else
+ /* XXX the next two statements won't work if short isn't 16 bits */
+ fs->min_bounds = * (XCharStruct *) &reply.minBounds;
+ fs->max_bounds = * (XCharStruct *) &reply.maxBounds;
+#endif /* MUSTCOPY */
+
+ fs->n_properties = reply.nFontProps;
+ /*
+ * if no properties defined for the font, then it is bad
+ * font, but shouldn't try to read nothing.
+ */
+ fs->properties = NULL;
+ if (fs->n_properties > 0) {
+ nbytes = reply.nFontProps * sizeof(XFontProp);
+ fs->properties = (XFontProp *) Xmalloc ((unsigned) nbytes);
+ nbytes = reply.nFontProps * SIZEOF(xFontProp);
+ if (! fs->properties) {
+ Xfree((char *) fs);
+ _XEatData(dpy, (unsigned long)
+ (nbytes + reply.nCharInfos * SIZEOF(xCharInfo)));
+ return (XFontStruct *)NULL;
+ }
+ _XRead32 (dpy, (char *)fs->properties, nbytes);
+ }
+ /*
+ * If no characters in font, then it is a bad font, but
+ * shouldn't try to read nothing.
+ */
+ /* have to unpack charinfos on some machines (CRAY) */
+ fs->per_char = NULL;
+ if (reply.nCharInfos > 0){
+ nbytes = reply.nCharInfos * sizeof(XCharStruct);
+ if (! (fs->per_char = (XCharStruct *) Xmalloc ((unsigned) nbytes))) {
+ if (fs->properties) Xfree((char *) fs->properties);
+ Xfree((char *) fs);
+ _XEatData(dpy, (unsigned long)
+ (reply.nCharInfos * SIZEOF(xCharInfo)));
+ return (XFontStruct *)NULL;
+ }
+
+#ifdef MUSTCOPY
+ {
+ register XCharStruct *cs = fs->per_char;
+ register int i;
+
+ for (i = 0; i < reply.nCharInfos; i++, cs++) {
+ xCharInfo xcip;
+
+ _XRead(dpy, (char *)&xcip, SIZEOF(xCharInfo));
+ cs->lbearing = cvtINT16toShort(xcip.leftSideBearing);
+ cs->rbearing = cvtINT16toShort(xcip.rightSideBearing);
+ cs->width = cvtINT16toShort(xcip.characterWidth);
+ cs->ascent = cvtINT16toShort(xcip.ascent);
+ cs->descent = cvtINT16toShort(xcip.descent);
+ cs->attributes = xcip.attributes;
+ }
+ }
+#else
+ nbytes = reply.nCharInfos * SIZEOF(xCharInfo);
+ _XRead16 (dpy, (char *)fs->per_char, nbytes);
+#endif
+ }
+
+ /* call out to any extensions interested */
+ for (ext = dpy->ext_procs; ext; ext = ext->next)
+ if (ext->create_Font) (*ext->create_Font)(dpy, fs, &ext->codes);
+ return fs;
+}
+
+
+XFontStruct *XQueryFont (dpy, fid)
+ register Display *dpy;
+ Font fid;
+{
+ XFontStruct *font_result;
+
+ LockDisplay(dpy);
+ font_result = _XQueryFont(dpy, fid, 0L);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return font_result;
+}
+
+
+
diff --git a/src/FontInfo.c b/src/FontInfo.c
new file mode 100644
index 00000000..2dd4e793
--- /dev/null
+++ b/src/FontInfo.c
@@ -0,0 +1,248 @@
+/* $Xorg: FontInfo.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+#if NeedFunctionPrototypes
+char **XListFontsWithInfo(
+register Display *dpy,
+_Xconst char *pattern, /* null-terminated */
+int maxNames,
+int *actualCount, /* RETURN */
+XFontStruct **info) /* RETURN */
+#else
+char **XListFontsWithInfo(dpy, pattern, maxNames, actualCount, info)
+register Display *dpy;
+char *pattern; /* null-terminated */
+int maxNames;
+int *actualCount; /* RETURN */
+XFontStruct **info; /* RETURN */
+#endif
+{
+ register long nbytes;
+ register int i;
+ register XFontStruct *fs;
+ register int size = 0;
+ XFontStruct *finfo = NULL;
+ char **flist = NULL;
+ xListFontsWithInfoReply reply;
+ register xListFontsReq *req;
+ int j;
+
+ LockDisplay(dpy);
+ GetReq(ListFontsWithInfo, req);
+ req->maxNames = maxNames;
+ nbytes = req->nbytes = pattern ? strlen (pattern) : 0;
+ req->length += (nbytes + 3) >> 2;
+ _XSend (dpy, pattern, nbytes);
+ /* use _XSend instead of Data, since subsequent _XReply will flush buffer */
+
+ for (i = 0; ; i++) {
+ if (!_XReply (dpy, (xReply *) &reply,
+ ((SIZEOF(xListFontsWithInfoReply) -
+ SIZEOF(xGenericReply)) >> 2), xFalse)) {
+ for (j=(i-1); (j >= 0); j--) {
+ Xfree(flist[j]);
+ if (finfo[j].properties) Xfree((char *) finfo[j].properties);
+ }
+ if (flist) Xfree((char *) flist);
+ if (finfo) Xfree((char *) finfo);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return ((char **) NULL);
+ }
+ if (reply.nameLength == 0)
+ break;
+ if ((i + reply.nReplies) >= size) {
+ size = i + reply.nReplies + 1;
+
+ if (finfo) {
+ XFontStruct * tmp_finfo = (XFontStruct *)
+ Xrealloc ((char *) finfo,
+ (unsigned) (sizeof(XFontStruct) * size));
+ char ** tmp_flist = (char **)
+ Xrealloc ((char *) flist,
+ (unsigned) (sizeof(char *) * (size+1)));
+
+ if ((! tmp_finfo) || (! tmp_flist)) {
+ /* free all the memory that we allocated */
+ for (j=(i-1); (j >= 0); j--) {
+ Xfree(flist[j]);
+ if (finfo[j].properties)
+ Xfree((char *) finfo[j].properties);
+ }
+ if (tmp_flist) Xfree((char *) tmp_flist);
+ else Xfree((char *) flist);
+ if (tmp_finfo) Xfree((char *) tmp_finfo);
+ else Xfree((char *) finfo);
+ goto clearwire;
+ }
+ finfo = tmp_finfo;
+ flist = tmp_flist;
+ }
+ else {
+ if (! (finfo = (XFontStruct *)
+ Xmalloc((unsigned) (sizeof(XFontStruct) * size))))
+ goto clearwire;
+ if (! (flist = (char **)
+ Xmalloc((unsigned) (sizeof(char *) * (size+1))))) {
+ Xfree((char *) finfo);
+ goto clearwire;
+ }
+ }
+ }
+ fs = &finfo[i];
+
+ fs->ext_data = NULL;
+ fs->per_char = NULL;
+ fs->fid = None;
+ fs->direction = reply.drawDirection;
+ fs->min_char_or_byte2 = reply.minCharOrByte2;
+ fs->max_char_or_byte2 = reply.maxCharOrByte2;
+ fs->min_byte1 = reply.minByte1;
+ fs->max_byte1 = reply.maxByte1;
+ fs->default_char = reply.defaultChar;
+ fs->all_chars_exist = reply.allCharsExist;
+ fs->ascent = cvtINT16toInt (reply.fontAscent);
+ fs->descent = cvtINT16toInt (reply.fontDescent);
+
+#ifdef MUSTCOPY
+ {
+ xCharInfo *xcip;
+
+ xcip = (xCharInfo *) &reply.minBounds;
+ fs->min_bounds.lbearing = xcip->leftSideBearing;
+ fs->min_bounds.rbearing = xcip->rightSideBearing;
+ fs->min_bounds.width = xcip->characterWidth;
+ fs->min_bounds.ascent = xcip->ascent;
+ fs->min_bounds.descent = xcip->descent;
+ fs->min_bounds.attributes = xcip->attributes;
+
+ xcip = (xCharInfo *) &reply.maxBounds;
+ fs->max_bounds.lbearing = xcip->leftSideBearing;
+ fs->max_bounds.rbearing = xcip->rightSideBearing;
+ fs->max_bounds.width = xcip->characterWidth;
+ fs->max_bounds.ascent = xcip->ascent;
+ fs->max_bounds.descent = xcip->descent;
+ fs->max_bounds.attributes = xcip->attributes;
+ }
+#else
+ /* XXX the next two statements won't work if short isn't 16 bits */
+ fs->min_bounds = * (XCharStruct *) &reply.minBounds;
+ fs->max_bounds = * (XCharStruct *) &reply.maxBounds;
+#endif /* MUSTCOPY */
+
+ fs->n_properties = reply.nFontProps;
+ if (fs->n_properties > 0) {
+ nbytes = reply.nFontProps * sizeof(XFontProp);
+ if (! (fs->properties = (XFontProp *) Xmalloc((unsigned) nbytes)))
+ goto badmem;
+ nbytes = reply.nFontProps * SIZEOF(xFontProp);
+ _XRead32 (dpy, (char *)fs->properties, nbytes);
+
+ } else
+ fs->properties = NULL;
+
+ j = reply.nameLength + 1;
+ if (!i)
+ j++; /* make first string 1 byte longer, to match XListFonts */
+ flist[i] = (char *) Xmalloc ((unsigned int) j);
+ if (! flist[i]) {
+ if (finfo[i].properties) Xfree((char *) finfo[i].properties);
+ nbytes = reply.nameLength + 3 & ~3;
+ _XEatData(dpy, (unsigned long) nbytes);
+ goto badmem;
+ }
+ if (!i) {
+ *flist[0] = 0; /* zero to distinguish from XListFonts */
+ flist[0]++;
+ }
+ flist[i][reply.nameLength] = '\0';
+ _XReadPad (dpy, flist[i], (long) reply.nameLength);
+ }
+ *info = finfo;
+ *actualCount = i;
+ if (flist)
+ flist[i] = NULL; /* required in case XFreeFontNames is called */
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (flist);
+
+
+ badmem:
+ /* Free all memory allocated by this function. */
+ for (j=(i-1); (j >= 0); j--) {
+ Xfree(flist[j]);
+ if (finfo[j].properties) Xfree((char *) finfo[j].properties);
+ }
+ if (flist) Xfree((char *) flist);
+ if (finfo) Xfree((char *) finfo);
+
+ clearwire:
+ /* Clear the wire. */
+ do {
+ if (reply.nFontProps)
+ _XEatData(dpy, (unsigned long)
+ (reply.nFontProps * SIZEOF(xFontProp)));
+ nbytes = (reply.nameLength + 3) & ~3;
+ _XEatData(dpy, (unsigned long) nbytes);
+ }
+ while (_XReply(dpy,(xReply *) &reply, ((SIZEOF(xListFontsWithInfoReply) -
+ SIZEOF(xGenericReply)) >> 2),
+ xFalse) && (reply.nameLength != 0));
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (char **) NULL;
+}
+
+
+XFreeFontInfo (names, info, actualCount)
+char **names;
+XFontStruct *info;
+int actualCount;
+{
+ register int i;
+ if (names) {
+ Xfree (names[0]-1);
+ for (i = 1; i < actualCount; i++) {
+ Xfree (names[i]);
+ }
+ Xfree((char *) names);
+ }
+ if (info) {
+ for (i = 0; i < actualCount; i++) {
+ if (info[i].per_char)
+ Xfree ((char *) info[i].per_char);
+ if (info[i].properties)
+ Xfree ((char *) info[i].properties);
+ }
+ Xfree((char *) info);
+ }
+ return 1;
+}
diff --git a/src/FontNames.c b/src/FontNames.c
new file mode 100644
index 00000000..8432b2f9
--- /dev/null
+++ b/src/FontNames.c
@@ -0,0 +1,118 @@
+/* $Xorg: FontNames.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+#if NeedFunctionPrototypes
+char **XListFonts(
+register Display *dpy,
+_Xconst char *pattern, /* null-terminated */
+int maxNames,
+int *actualCount) /* RETURN */
+#else
+char **XListFonts(dpy, pattern, maxNames, actualCount)
+register Display *dpy;
+char *pattern; /* null-terminated */
+int maxNames;
+int *actualCount; /* RETURN */
+#endif
+{
+ register long nbytes;
+ register unsigned i;
+ register int length;
+ char **flist;
+ char *ch;
+ xListFontsReply rep;
+ register xListFontsReq *req;
+ register long rlen;
+
+ LockDisplay(dpy);
+ GetReq(ListFonts, req);
+ req->maxNames = maxNames;
+ nbytes = req->nbytes = pattern ? strlen (pattern) : 0;
+ req->length += (nbytes + 3) >> 2;
+ _XSend (dpy, pattern, nbytes);
+ /* use _XSend instead of Data, since following _XReply will flush buffer */
+
+ if (!_XReply (dpy, (xReply *)&rep, 0, xFalse)) {
+ *actualCount = 0;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (char **) NULL;
+ }
+
+ if (rep.nFonts) {
+ flist = (char **)Xmalloc ((unsigned)rep.nFonts * sizeof(char *));
+ rlen = rep.length << 2;
+ ch = (char *) Xmalloc((unsigned) (rlen + 1));
+ /* +1 to leave room for last null-terminator */
+
+ if ((! flist) || (! ch)) {
+ if (flist) Xfree((char *) flist);
+ if (ch) Xfree(ch);
+ _XEatData(dpy, (unsigned long) rlen);
+ *actualCount = 0;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (char **) NULL;
+ }
+
+ _XReadPad (dpy, ch, rlen);
+ /*
+ * unpack into null terminated strings.
+ */
+ length = *(unsigned char *)ch;
+ *ch = 1; /* make sure it is non-zero for XFreeFontNames */
+ for (i = 0; i < rep.nFonts; i++) {
+ flist[i] = ch + 1; /* skip over length */
+ ch += length + 1; /* find next length ... */
+ length = *(unsigned char *)ch;
+ *ch = '\0'; /* and replace with null-termination */
+ }
+ }
+ else flist = (char **) NULL;
+ *actualCount = rep.nFonts;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (flist);
+}
+
+XFreeFontNames(list)
+char **list;
+{
+ if (list) {
+ if (!*(list[0]-1)) { /* from ListFontsWithInfo */
+ register char **names;
+ for (names = list+1; *names; names++)
+ Xfree (*names);
+ }
+ Xfree (list[0]-1);
+ Xfree ((char *)list);
+ }
+ return 1;
+}
diff --git a/src/FreeCmap.c b/src/FreeCmap.c
new file mode 100644
index 00000000..3a2d370c
--- /dev/null
+++ b/src/FreeCmap.c
@@ -0,0 +1,46 @@
+/* $Xorg: FreeCmap.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+extern void _XcmsDeleteCmapRec();
+
+XFreeColormap(dpy, cmap)
+register Display *dpy;
+Colormap cmap;
+{
+ register xResourceReq *req;
+
+ LockDisplay(dpy);
+ GetResReq(FreeColormap, cmap, req);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ _XcmsDeleteCmapRec(dpy, cmap);
+ return 1;
+}
diff --git a/src/FreeCols.c b/src/FreeCols.c
new file mode 100644
index 00000000..03f74b90
--- /dev/null
+++ b/src/FreeCols.c
@@ -0,0 +1,54 @@
+/* $Xorg: FreeCols.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XFreeColors(dpy, cmap, pixels, npixels, planes)
+register Display *dpy;
+Colormap cmap;
+unsigned long *pixels; /* LISTofCARD32 */
+int npixels;
+unsigned long planes; /* CARD32 */
+{
+ register xFreeColorsReq *req;
+ register long nbytes;
+
+ LockDisplay(dpy);
+ GetReq(FreeColors, req);
+ req->cmap = cmap;
+ req->planeMask = planes;
+
+ /* on the VAX, each pixel is a 32-bit (unsigned) integer */
+ req->length += npixels;
+
+ nbytes = npixels << 2; /* watch out for macros... */
+ Data32 (dpy, (long *) pixels, nbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/FreeCurs.c b/src/FreeCurs.c
new file mode 100644
index 00000000..4fe214a9
--- /dev/null
+++ b/src/FreeCurs.c
@@ -0,0 +1,41 @@
+/* $Xorg: FreeCurs.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XFreeCursor(dpy, cursor)
+ register Display *dpy;
+ Cursor cursor;
+{
+ register xResourceReq *req;
+ LockDisplay(dpy);
+ GetResReq(FreeCursor, cursor, req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/FreeEData.c b/src/FreeEData.c
new file mode 100644
index 00000000..14344fb8
--- /dev/null
+++ b/src/FreeEData.c
@@ -0,0 +1,43 @@
+/* $Xorg: FreeEData.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+_XFreeExtData (extension)
+ XExtData *extension;
+{
+ XExtData *temp;
+ while (extension) {
+ if (extension->free_private)
+ (*extension->free_private)(extension);
+ else Xfree ((char *)extension->private_data);
+ temp = extension->next;
+ Xfree ((char *)extension);
+ extension = temp;
+ }
+ return 0;
+}
diff --git a/src/FreeGC.c b/src/FreeGC.c
new file mode 100644
index 00000000..9912ff6f
--- /dev/null
+++ b/src/FreeGC.c
@@ -0,0 +1,47 @@
+/* $Xorg: FreeGC.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XFreeGC (dpy, gc)
+ register Display *dpy;
+ GC gc;
+ {
+ register xResourceReq *req;
+ register _XExtension *ext;
+ LockDisplay(dpy);
+ /* call out to any extensions interested */
+ for (ext = dpy->ext_procs; ext; ext = ext->next)
+ if (ext->free_GC) (*ext->free_GC)(dpy, gc, &ext->codes);
+ GetResReq (FreeGC, gc->gid, req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ _XFreeExtData(gc->ext_data);
+ Xfree ((char *) gc);
+ return 1;
+ }
+
diff --git a/src/FreePix.c b/src/FreePix.c
new file mode 100644
index 00000000..d90ae131
--- /dev/null
+++ b/src/FreePix.c
@@ -0,0 +1,42 @@
+/* $Xorg: FreePix.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XFreePixmap(dpy, pixmap)
+ register Display *dpy;
+ Pixmap pixmap;
+
+{
+ register xResourceReq *req;
+ LockDisplay(dpy);
+ GetResReq(FreePixmap, pixmap, req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/GCMisc.c b/src/GCMisc.c
new file mode 100644
index 00000000..3735f692
--- /dev/null
+++ b/src/GCMisc.c
@@ -0,0 +1,103 @@
+/* $Xorg: GCMisc.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XSetArcMode (dpy, gc, arc_mode)
+register Display *dpy;
+register GC gc;
+int arc_mode;
+{
+ LockDisplay(dpy);
+ if (gc->values.arc_mode != arc_mode) {
+ gc->values.arc_mode = arc_mode;
+ gc->dirty |= GCArcMode;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+XSetFillRule (dpy, gc, fill_rule)
+register Display *dpy;
+register GC gc;
+int fill_rule;
+{
+ LockDisplay(dpy);
+ if (gc->values.fill_rule != fill_rule) {
+ gc->values.fill_rule = fill_rule;
+ gc->dirty |= GCFillRule;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+XSetFillStyle (dpy, gc, fill_style)
+register Display *dpy;
+register GC gc;
+int fill_style;
+{
+ LockDisplay(dpy);
+ if (gc->values.fill_style != fill_style) {
+ gc->values.fill_style = fill_style;
+ gc->dirty |= GCFillStyle;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+XSetGraphicsExposures (dpy, gc, graphics_exposures)
+register Display *dpy;
+register GC gc;
+Bool graphics_exposures;
+{
+ LockDisplay(dpy);
+ if (gc->values.graphics_exposures != graphics_exposures) {
+ gc->values.graphics_exposures = graphics_exposures;
+ gc->dirty |= GCGraphicsExposures;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+XSetSubwindowMode (dpy, gc, subwindow_mode)
+register Display *dpy;
+register GC gc;
+int subwindow_mode;
+{
+ LockDisplay(dpy);
+ if (gc->values.subwindow_mode != subwindow_mode) {
+ gc->values.subwindow_mode = subwindow_mode;
+ gc->dirty |= GCSubwindowMode;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/Geom.c b/src/Geom.c
new file mode 100644
index 00000000..2699231d
--- /dev/null
+++ b/src/Geom.c
@@ -0,0 +1,98 @@
+/* $Xorg: Geom.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+
+/*
+
+Copyright 1985, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+#include "Xutil.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.
+ */
+
+#if NeedFunctionPrototypes
+int XGeometry (
+ Display *dpy, /* user's display connection */
+ int screen, /* screen on which to do computation */
+ _Xconst char *pos, /* user provided geometry spec */
+ _Xconst char *def, /* default geometry spec for window */
+ unsigned int bwidth, /* border width */
+ unsigned int fwidth, /* size of position units */
+ unsigned int fheight,
+ int xadd, /* any additional interior space */
+ int yadd,
+ register int *x, /* always set on successful RETURN */
+ register int *y, /* always set on successful RETURN */
+ register int *width, /* always set on successful RETURN */
+ register int *height) /* always set on successful RETURN */
+#else
+int XGeometry (dpy, screen, pos, def, bwidth, fwidth, fheight, xadd, yadd, x, y, width, height)
+ Display *dpy; /* user's display connection */
+ int screen; /* screen on which to do computation */
+ char *pos; /* user provided geometry spec */
+ char *def; /* default geometry spec for window */
+ unsigned int bwidth; /* border width */
+ unsigned int fwidth, fheight; /* size of position units */
+ int xadd, yadd; /* any additional interior space */
+ register int *x, *y, *width, *height;/* always set on successful RETURN */
+#endif
+{
+ int px, py; /* returned values from parse */
+ unsigned int pwidth, pheight; /* returned values from parse */
+ int dx, dy; /* default values from parse */
+ unsigned int 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(dpy, screen) + dx - dwidth * fwidth -
+ 2 * bwidth - xadd : dx;
+ *y = (dmask & YNegative) ?
+ DisplayHeight(dpy, screen) + 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(dpy, screen) + px - *width * fwidth -
+ 2 * bwidth - xadd : px;
+ if (pmask & YValue)
+ *y = (pmask & YNegative) ?
+ DisplayHeight(dpy, screen) + py - *height * fheight -
+ 2 * bwidth - yadd : py;
+ return (pmask);
+}
diff --git a/src/GetAtomNm.c b/src/GetAtomNm.c
new file mode 100644
index 00000000..1b11fd7a
--- /dev/null
+++ b/src/GetAtomNm.c
@@ -0,0 +1,204 @@
+/* $Xorg: GetAtomNm.c,v 1.5 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+extern void _XFreeAtomTable();
+
+/* XXX this table def is duplicated in IntAtom.c, keep them consistent! */
+
+#define TABLESIZE 64
+
+typedef struct _Entry {
+ unsigned long sig;
+ Atom atom;
+} EntryRec, *Entry;
+
+#define EntryName(e) ((char *)(e+1))
+
+typedef struct _XDisplayAtoms {
+ Entry table[TABLESIZE];
+} AtomTable;
+
+static
+char *_XGetAtomName(dpy, atom)
+ Display *dpy;
+ Atom atom;
+{
+ xResourceReq *req;
+ char *name;
+ register Entry *table;
+ register int idx;
+ register Entry e;
+
+ if (dpy->atoms) {
+ table = dpy->atoms->table;
+ for (idx = TABLESIZE; --idx >= 0; ) {
+ if ((e = *table++) && (e->atom == atom)) {
+ idx = strlen(EntryName(e)) + 1;
+ if ((name = (char *)Xmalloc(idx)))
+ strcpy(name, EntryName(e));
+ return name;
+ }
+ }
+ }
+ GetResReq(GetAtomName, atom, req);
+ return (char *)NULL;
+}
+
+char *XGetAtomName(dpy, atom)
+ register Display *dpy;
+ Atom atom;
+{
+ xGetAtomNameReply rep;
+ char *name;
+
+ LockDisplay(dpy);
+ if ((name = _XGetAtomName(dpy, atom))) {
+ UnlockDisplay(dpy);
+ return name;
+ }
+ if (_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(NULL);
+ }
+ if ((name = (char *) Xmalloc(rep.nameLength+1))) {
+ _XReadPad(dpy, name, (long)rep.nameLength);
+ name[rep.nameLength] = '\0';
+ _XUpdateAtomCache(dpy, name, atom, 0, -1, 0);
+ } else {
+ _XEatData(dpy, (unsigned long) (rep.nameLength + 3) & ~3);
+ name = (char *) NULL;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(name);
+}
+
+typedef struct {
+ unsigned long start_seq;
+ unsigned long stop_seq;
+ Atom *atoms;
+ char **names;
+ int idx;
+ int count;
+ Status status;
+} _XGetAtomNameState;
+
+static
+Bool _XGetAtomNameHandler(dpy, rep, buf, len, data)
+ register Display *dpy;
+ register xReply *rep;
+ char *buf;
+ int len;
+ XPointer data;
+{
+ register _XGetAtomNameState *state;
+ xGetAtomNameReply replbuf;
+ register xGetAtomNameReply *repl;
+
+ state = (_XGetAtomNameState *)data;
+ if (dpy->last_request_read < state->start_seq ||
+ dpy->last_request_read > state->stop_seq)
+ return False;
+ while (state->idx < state->count && state->names[state->idx])
+ state->idx++;
+ if (state->idx >= state->count)
+ return False;
+ if (rep->generic.type == X_Error) {
+ state->status = 0;
+ return False;
+ }
+ repl = (xGetAtomNameReply *)
+ _XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len,
+ (SIZEOF(xGetAtomNameReply) - SIZEOF(xReply)) >> 2,
+ False);
+ state->names[state->idx] = (char *) Xmalloc(repl->nameLength+1);
+ _XGetAsyncData(dpy, state->names[state->idx], buf, len,
+ SIZEOF(xGetAtomNameReply), repl->nameLength,
+ repl->length << 2);
+ if (state->names[state->idx]) {
+ state->names[state->idx][repl->nameLength] = '\0';
+ _XUpdateAtomCache(dpy, state->names[state->idx],
+ state->atoms[state->idx], 0, -1, 0);
+ } else {
+ state->status = 0;
+ }
+ return True;
+}
+
+Status
+XGetAtomNames (dpy, atoms, count, names_return)
+ Display *dpy;
+ Atom *atoms;
+ int count;
+ char **names_return;
+{
+ _XAsyncHandler async;
+ _XGetAtomNameState async_state;
+ xGetAtomNameReply rep;
+ int i;
+ int missed = -1;
+
+ LockDisplay(dpy);
+ async_state.start_seq = dpy->request + 1;
+ async_state.atoms = atoms;
+ async_state.names = names_return;
+ async_state.idx = 0;
+ async_state.count = count - 1;
+ async_state.status = 1;
+ async.next = dpy->async_handlers;
+ async.handler = _XGetAtomNameHandler;
+ async.data = (XPointer)&async_state;
+ dpy->async_handlers = &async;
+ for (i = 0; i < count; i++) {
+ if (!(names_return[i] = _XGetAtomName(dpy, atoms[i]))) {
+ missed = i;
+ async_state.stop_seq = dpy->request;
+ }
+ }
+ if (missed >= 0) {
+ if (_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ if ((names_return[missed] = (char *) Xmalloc(rep.nameLength+1))) {
+ _XReadPad(dpy, names_return[missed], (long)rep.nameLength);
+ names_return[missed][rep.nameLength] = '\0';
+ _XUpdateAtomCache(dpy, names_return[missed], atoms[missed],
+ 0, -1, 0);
+ } else {
+ _XEatData(dpy, (unsigned long) (rep.nameLength + 3) & ~3);
+ async_state.status = 0;
+ }
+ }
+ }
+ DeqAsyncHandler(dpy, &async);
+ UnlockDisplay(dpy);
+ if (missed >= 0)
+ SyncHandle();
+ return async_state.status;
+}
diff --git a/src/GetColor.c b/src/GetColor.c
new file mode 100644
index 00000000..b469b5d4
--- /dev/null
+++ b/src/GetColor.c
@@ -0,0 +1,111 @@
+/* $Xorg: GetColor.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include <stdio.h>
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+extern void _XcmsRGB_to_XColor();
+
+#if NeedFunctionPrototypes
+Status XAllocNamedColor(
+register Display *dpy,
+Colormap cmap,
+_Xconst char *colorname, /* STRING8 */
+XColor *hard_def, /* RETURN */
+XColor *exact_def) /* RETURN */
+#else
+Status XAllocNamedColor(dpy, cmap, colorname, hard_def, exact_def)
+register Display *dpy;
+Colormap cmap;
+char *colorname; /* STRING8 */
+XColor *hard_def; /* RETURN */
+XColor *exact_def; /* RETURN */
+#endif
+{
+
+ long nbytes;
+ xAllocNamedColorReply rep;
+ xAllocNamedColorReq *req;
+
+ XcmsCCC ccc;
+ XcmsColor cmsColor_exact;
+ Status ret;
+
+ /*
+ * Let's Attempt to use Xcms and i18n approach to Parse Color
+ */
+ /* copy string to allow overwrite by _XcmsResolveColorString() */
+ if ((ccc = XcmsCCCOfColormap(dpy, cmap)) != (XcmsCCC)NULL) {
+ if (_XcmsResolveColorString(ccc, &colorname, &cmsColor_exact,
+ XcmsRGBFormat) >= XcmsSuccess) {
+ _XcmsRGB_to_XColor(&cmsColor_exact, exact_def, 1);
+ memcpy((char *)hard_def, (char *)exact_def, sizeof(XColor));
+ ret = XAllocColor(dpy, cmap, hard_def);
+ exact_def->pixel = hard_def->pixel;
+ return(ret);
+ }
+ /*
+ * Otherwise we failed; or colorname was changed with yet another
+ * name. Thus pass name to the X Server.
+ */
+ }
+
+ /*
+ * Xcms and i18n approach failed.
+ */
+ LockDisplay(dpy);
+ GetReq(AllocNamedColor, req);
+
+ req->cmap = cmap;
+ nbytes = req->nbytes = strlen(colorname);
+ req->length += (nbytes + 3) >> 2; /* round up to mult of 4 */
+
+ _XSend(dpy, colorname, nbytes);
+ /* _XSend is more efficient that Data, since _XReply follows */
+
+ if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (0);
+ }
+
+ exact_def->red = rep.exactRed;
+ exact_def->green = rep.exactGreen;
+ exact_def->blue = rep.exactBlue;
+
+ hard_def->red = rep.screenRed;
+ hard_def->green = rep.screenGreen;
+ hard_def->blue = rep.screenBlue;
+
+ exact_def->pixel = hard_def->pixel = rep.pixel;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (1);
+}
diff --git a/src/GetDflt.c b/src/GetDflt.c
new file mode 100644
index 00000000..6e05abd4
--- /dev/null
+++ b/src/GetDflt.c
@@ -0,0 +1,247 @@
+/* $Xorg: GetDflt.c,v 1.6 2001/02/09 02:03:33 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#include "Xlibint.h"
+#include <X11/Xos.h>
+#include <X11/Xresource.h>
+
+#ifndef X_NOT_POSIX
+#ifdef _POSIX_SOURCE
+#include <limits.h>
+#else
+#define _POSIX_SOURCE
+#include <limits.h>
+#undef _POSIX_SOURCE
+#endif
+#endif
+#ifndef PATH_MAX
+#ifdef WIN32
+#define PATH_MAX 512
+#else
+#include <sys/param.h>
+#endif
+#ifndef PATH_MAX
+#ifdef MAXPATHLEN
+#define PATH_MAX MAXPATHLEN
+#else
+#define PATH_MAX 1024
+#endif
+#endif
+#endif
+
+#ifdef XTHREADS
+#include <X11/Xthreads.h>
+#endif
+#ifndef WIN32
+#define X_INCLUDE_PWD_H
+#define XOS_USE_XLIB_LOCKING
+#include <X11/Xos_r.h>
+#endif
+#include <stdio.h>
+#include <ctype.h>
+
+#ifdef X_NOT_STDC_ENV
+extern char *getenv();
+#endif
+
+/*ARGSUSED*/
+static char *GetHomeDir (dest, len)
+ char *dest;
+ int len;
+{
+#ifdef WIN32
+ register char *ptr1;
+ register char *ptr2;
+ int len1 = 0, len2 = 0;
+
+ if (ptr1 = getenv("HOME")) { /* old, deprecated */
+ len1 = strlen (ptr1);
+ } else if ((ptr1 = getenv("HOMEDRIVE")) && (ptr2 = getenv("HOMEDIR"))) {
+ len1 = strlen (ptr1);
+ len2 = strlen (ptr2);
+ } else if (ptr2 = getenv("USERNAME")) {
+ len1 = strlen (ptr1 = "/users/");
+ len2 = strlen (ptr2);
+ }
+ if ((len1 + len2 + 1) < len)
+ sprintf (dest, "%s%s", ptr1, (ptr2) ? ptr2 : "");
+ else
+ *dest = '\0';
+#else
+ _Xgetpwparams pwparams;
+ struct passwd *pw;
+ register char *ptr;
+
+ if (len <= 0 || dest == NULL)
+ return NULL;
+
+ if ((ptr = getenv("HOME"))) {
+ (void) strncpy(dest, ptr, len);
+ dest[len-1] = '\0';
+ } else {
+ if ((ptr = getenv("USER")))
+ pw = _XGetpwnam(ptr,pwparams);
+ else
+ pw = _XGetpwuid(getuid(),pwparams);
+ if (pw != NULL) {
+ (void) strncpy(dest, pw->pw_dir, len);
+ dest[len-1] = '\0';
+ } else
+ *dest = '\0';
+ }
+#endif
+ return dest;
+}
+
+
+static XrmDatabase InitDefaults (dpy)
+ Display *dpy; /* display for defaults.... */
+{
+ XrmDatabase userdb;
+ XrmDatabase xdb;
+ char fname[PATH_MAX]; /* longer than any conceivable size */
+ char *xenv;
+
+ XrmInitialize();
+
+ /*
+ * See lib/Xt/Initialize.c
+ *
+ * First, get the defaults from the server; if none, then load from
+ * ~/.Xdefaults. Next, if there is an XENVIRONMENT environment variable,
+ * then load that file.
+ */
+
+ if (dpy->xdefaults == NULL) {
+ char *slashDotXdefaults = "/.Xdefaults";
+
+ (void) GetHomeDir (fname, PATH_MAX - strlen (slashDotXdefaults) - 1);
+ (void) strcat (fname, slashDotXdefaults);
+ xdb = XrmGetFileDatabase (fname);
+ } else {
+ xdb = XrmGetStringDatabase(dpy->xdefaults);
+ }
+
+ if (!(xenv = getenv ("XENVIRONMENT"))) {
+ char *slashDotXdefaultsDash = "/.Xdefaults-";
+ int len;
+
+ (void) GetHomeDir (fname, PATH_MAX - strlen (slashDotXdefaultsDash) - 1);
+ (void) strcat (fname, slashDotXdefaultsDash);
+ len = strlen (fname);
+ (void) _XGetHostname (fname+len, PATH_MAX-len);
+ xenv = fname;
+ }
+ userdb = XrmGetFileDatabase (xenv);
+ XrmMergeDatabases (userdb, &xdb);
+ return (xdb);
+
+#ifdef old
+ if (fname[0] != '\0') userdb = XrmGetFileDatabase(fname);
+ xdb = XrmGetStringDatabase(dpy->xdefaults);
+ XrmMergeDatabases(userdb, &xdb);
+ return xdb;
+#endif
+}
+
+#if NeedFunctionPrototypes
+char *XGetDefault(
+ Display *dpy, /* display for defaults.... */
+ char _Xconst *prog, /* name of program for option */
+ register _Xconst char *name) /* name of option program wants */
+#else
+char *XGetDefault(dpy, prog, name)
+ Display *dpy; /* display for defaults.... */
+ char *prog; /* name of program for option */
+ register char *name; /* name of option program wants */
+#endif
+{ /* to get, for example, "font" */
+ XrmName names[3];
+ XrmClass classes[3];
+ XrmRepresentation fromType;
+ XrmValue result;
+ char *progname;
+#ifdef WIN32
+ char *progname2;
+#endif
+
+ /*
+ * strip path off of program name (XXX - this is OS specific)
+ */
+ progname = strrchr (prog, '/');
+#ifdef WIN32
+ progname2 = strrchr (prog, '\\');
+ if (progname2 && (!progname || progname < progname2))
+ progname = progname2;
+#endif
+ if (progname)
+ progname++;
+ else
+ progname = (char *)prog;
+
+ /*
+ * see if database has ever been initialized. Lookups can be done
+ * without locks held.
+ */
+ LockDisplay(dpy);
+ if (dpy->db == NULL) {
+ dpy->db = InitDefaults(dpy);
+ }
+ UnlockDisplay(dpy);
+
+ names[0] = XrmStringToName(progname);
+ names[1] = XrmStringToName(name);
+ names[2] = NULLQUARK;
+ classes[0] = XrmStringToClass("Program");
+ classes[1] = XrmStringToClass("Name");
+ classes[2] = NULLQUARK;
+ (void)XrmQGetResource(dpy->db, names, classes, &fromType, &result);
+ return (result.addr);
+}
+
diff --git a/src/GetFPath.c b/src/GetFPath.c
new file mode 100644
index 00000000..69dd809c
--- /dev/null
+++ b/src/GetFPath.c
@@ -0,0 +1,90 @@
+/* $Xorg: GetFPath.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+char **XGetFontPath(dpy, npaths)
+register Display *dpy;
+int *npaths; /* RETURN */
+{
+ xGetFontPathReply rep;
+ register long nbytes;
+ char **flist;
+ char *ch;
+ register unsigned i;
+ register int length;
+ register xReq *req;
+
+ LockDisplay(dpy);
+ GetEmptyReq (GetFontPath, req);
+ (void) _XReply (dpy, (xReply *) &rep, 0, xFalse);
+
+ if (rep.nPaths) {
+ flist = (char **)
+ Xmalloc((unsigned) rep.nPaths * sizeof (char *));
+ nbytes = (long)rep.length << 2;
+ ch = (char *) Xmalloc ((unsigned) (nbytes + 1));
+ /* +1 to leave room for last null-terminator */
+
+ if ((! flist) || (! ch)) {
+ if (flist) Xfree((char *) flist);
+ if (ch) Xfree(ch);
+ _XEatData(dpy, (unsigned long) nbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (char **) NULL;
+ }
+
+ _XReadPad (dpy, ch, nbytes);
+ /*
+ * unpack into null terminated strings.
+ */
+ length = *ch;
+ for (i = 0; i < rep.nPaths; i++) {
+ flist[i] = ch+1; /* skip over length */
+ ch += length + 1; /* find next length ... */
+ length = *ch;
+ *ch = '\0'; /* and replace with null-termination */
+ }
+ }
+ else flist = NULL;
+ *npaths = rep.nPaths;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (flist);
+}
+
+XFreeFontPath (list)
+char **list;
+{
+ if (list != NULL) {
+ Xfree (list[0]-1);
+ Xfree ((char *)list);
+ }
+ return 1;
+}
diff --git a/src/GetFProp.c b/src/GetFProp.c
new file mode 100644
index 00000000..f588c2f0
--- /dev/null
+++ b/src/GetFProp.c
@@ -0,0 +1,53 @@
+/* $Xorg: GetFProp.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+Bool XGetFontProperty (fs, name, valuePtr)
+ XFontStruct *fs;
+ register Atom name;
+ unsigned long *valuePtr;
+ {
+ /* XXX this is a simple linear search for now. If the
+ protocol is changed to sort the property list, this should
+ become a binary search. */
+ register XFontProp *prop = fs->properties;
+ register XFontProp *last = prop + fs->n_properties;
+ while (prop != last) {
+ if (prop->name == name) {
+ *valuePtr = prop->card32;
+ return (1);
+ }
+ prop++;
+ }
+ return (0);
+ }
+
+
+
+
+
diff --git a/src/GetGCVals.c b/src/GetGCVals.c
new file mode 100644
index 00000000..e8875869
--- /dev/null
+++ b/src/GetGCVals.c
@@ -0,0 +1,126 @@
+/* $Xorg: GetGCVals.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+
+/*
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+/*
+ * All gc fields except GCClipMask and GCDashList
+ */
+#define ValidGCValuesBits (GCFunction | GCPlaneMask | GCForeground | \
+ GCBackground | GCLineWidth | GCLineStyle | \
+ GCCapStyle | GCJoinStyle | GCFillStyle | \
+ GCFillRule | GCTile | GCStipple | \
+ GCTileStipXOrigin | GCTileStipYOrigin | \
+ GCFont | GCSubwindowMode | GCGraphicsExposures | \
+ GCClipXOrigin | GCClipYOrigin | GCDashOffset | \
+ GCArcMode)
+
+/*ARGSUSED*/
+Status XGetGCValues (dpy, gc, valuemask, values)
+ Display *dpy;
+ GC gc;
+ unsigned long valuemask;
+ XGCValues *values;
+{
+ if (valuemask == ValidGCValuesBits) {
+ char dashes = values->dashes;
+ Pixmap clip_mask = values->clip_mask;
+ *values = gc->values;
+ values->dashes = dashes;
+ values->clip_mask = clip_mask;
+ return True;
+ }
+
+ if (valuemask & ~ValidGCValuesBits) return False;
+
+ if (valuemask & GCFunction)
+ values->function = gc->values.function;
+
+ if (valuemask & GCPlaneMask)
+ values->plane_mask = gc->values.plane_mask;
+
+ if (valuemask & GCForeground)
+ values->foreground = gc->values.foreground;
+
+ if (valuemask & GCBackground)
+ values->background = gc->values.background;
+
+ if (valuemask & GCLineWidth)
+ values->line_width = gc->values.line_width;
+
+ if (valuemask & GCLineStyle)
+ values->line_style = gc->values.line_style;
+
+ if (valuemask & GCCapStyle)
+ values->cap_style = gc->values.cap_style;
+
+ if (valuemask & GCJoinStyle)
+ values->join_style = gc->values.join_style;
+
+ if (valuemask & GCFillStyle)
+ values->fill_style = gc->values.fill_style;
+
+ if (valuemask & GCFillRule)
+ values->fill_rule = gc->values.fill_rule;
+
+ if (valuemask & GCTile)
+ values->tile = gc->values.tile;
+
+ if (valuemask & GCStipple)
+ values->stipple = gc->values.stipple;
+
+ if (valuemask & GCTileStipXOrigin)
+ values->ts_x_origin = gc->values.ts_x_origin;
+
+ if (valuemask & GCTileStipYOrigin)
+ values->ts_y_origin = gc->values.ts_y_origin;
+
+ if (valuemask & GCFont)
+ values->font = gc->values.font;
+
+ if (valuemask & GCSubwindowMode)
+ values->subwindow_mode = gc->values.subwindow_mode;
+
+ if (valuemask & GCGraphicsExposures)
+ values->graphics_exposures = gc->values.graphics_exposures;
+
+ if (valuemask & GCClipXOrigin)
+ values->clip_x_origin = gc->values.clip_x_origin;
+
+ if (valuemask & GCClipYOrigin)
+ values->clip_y_origin = gc->values.clip_y_origin;
+
+ if (valuemask & GCDashOffset)
+
+ values->dash_offset = gc->values.dash_offset;
+
+ if (valuemask & GCArcMode)
+ values->arc_mode = gc->values.arc_mode;
+
+ return True;
+}
diff --git a/src/GetGeom.c b/src/GetGeom.c
new file mode 100644
index 00000000..367153f4
--- /dev/null
+++ b/src/GetGeom.c
@@ -0,0 +1,58 @@
+/* $Xorg: GetGeom.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+Status XGetGeometry (dpy, d, root, x, y, width, height, borderWidth, depth)
+ register Display *dpy;
+ Drawable d;
+ Window *root; /* RETURN */
+ int *x, *y; /* RETURN */
+ unsigned int *width, *height, *borderWidth, *depth; /* RETURN */
+{
+ xGetGeometryReply rep;
+ register xResourceReq *req;
+ LockDisplay(dpy);
+ GetResReq(GetGeometry, d, req);
+ if (!_XReply (dpy, (xReply *)&rep, 0, xTrue)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (0);
+ }
+ *root = rep.root;
+ *x = cvtINT16toInt (rep.x);
+ *y = cvtINT16toInt (rep.y);
+ *width = rep.width;
+ *height = rep.height;
+ *borderWidth = rep.borderWidth;
+ *depth = rep.depth;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (1);
+}
+
diff --git a/src/GetHColor.c b/src/GetHColor.c
new file mode 100644
index 00000000..33e6ad59
--- /dev/null
+++ b/src/GetHColor.c
@@ -0,0 +1,57 @@
+/* $Xorg: GetHColor.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+Status XAllocColor(dpy, cmap, def)
+register Display *dpy;
+Colormap cmap;
+XColor *def;
+{
+ Status status;
+ xAllocColorReply rep;
+ register xAllocColorReq *req;
+ LockDisplay(dpy);
+ GetReq(AllocColor, req);
+
+ req->cmap = cmap;
+ req->red = def->red;
+ req->green = def->green;
+ req->blue = def->blue;
+
+ status = _XReply(dpy, (xReply *) &rep, 0, xTrue);
+ if (status) {
+ def->pixel = rep.pixel;
+ def->red = rep.red;
+ def->green = rep.green;
+ def->blue = rep.blue;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(status);
+}
diff --git a/src/GetHints.c b/src/GetHints.c
new file mode 100644
index 00000000..7958fd1f
--- /dev/null
+++ b/src/GetHints.c
@@ -0,0 +1,337 @@
+/* $Xorg: GetHints.c,v 1.5 2001/02/09 02:03:33 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#include <X11/Xlibint.h>
+#include <X11/Xos.h>
+#include <X11/Xutil.h>
+#include "Xatomtype.h"
+#include <X11/Xatom.h>
+#include <stdio.h>
+
+Status XGetSizeHints (dpy, w, hints, property)
+ Display *dpy;
+ Window w;
+ XSizeHints *hints;
+ Atom property;
+{
+ xPropSizeHints *prop = NULL;
+ Atom actual_type;
+ int actual_format;
+ unsigned long leftover;
+ unsigned long nitems;
+ if (XGetWindowProperty(dpy, w, property, 0L,
+ (long) OldNumPropSizeElements,
+ False, XA_WM_SIZE_HINTS, &actual_type, &actual_format,
+ &nitems, &leftover, (unsigned char **)&prop)
+ != Success) return (0);
+
+ if ((actual_type != XA_WM_SIZE_HINTS) ||
+ (nitems < OldNumPropSizeElements) || (actual_format != 32)) {
+ if (prop != NULL) Xfree ((char *)prop);
+ return(0);
+ }
+ hints->flags = (prop->flags & (USPosition|USSize|PAllHints));
+ hints->x = cvtINT32toInt (prop->x);
+ hints->y = cvtINT32toInt (prop->y);
+ hints->width = cvtINT32toInt (prop->width);
+ hints->height = cvtINT32toInt (prop->height);
+ hints->min_width = cvtINT32toInt (prop->minWidth);
+ hints->min_height = cvtINT32toInt (prop->minHeight);
+ hints->max_width = cvtINT32toInt (prop->maxWidth);
+ hints->max_height = cvtINT32toInt (prop->maxHeight);
+ hints->width_inc = cvtINT32toInt (prop->widthInc);
+ hints->height_inc = cvtINT32toInt (prop->heightInc);
+ hints->min_aspect.x = cvtINT32toInt (prop->minAspectX);
+ hints->min_aspect.y = cvtINT32toInt (prop->minAspectY);
+ hints->max_aspect.x = cvtINT32toInt (prop->maxAspectX);
+ hints->max_aspect.y = cvtINT32toInt (prop->maxAspectY);
+ Xfree((char *)prop);
+ return(1);
+}
+
+/*
+ * must return a pointer to the hint, in malloc'd memory, or routine is not
+ * extensible; any use of the caller's memory would cause things to be stepped
+ * on.
+ */
+
+XWMHints *XGetWMHints (dpy, w)
+ Display *dpy;
+ Window w;
+{
+ xPropWMHints *prop = NULL;
+ register XWMHints *hints;
+ Atom actual_type;
+ int actual_format;
+ unsigned long leftover;
+ unsigned long nitems;
+ if (XGetWindowProperty(dpy, w, XA_WM_HINTS,
+ 0L, (long)NumPropWMHintsElements,
+ False, XA_WM_HINTS, &actual_type, &actual_format,
+ &nitems, &leftover, (unsigned char **)&prop)
+ != Success) return (NULL);
+
+ /* If the property is undefined on the window, return null pointer. */
+ /* pre-R3 bogusly truncated window_group, don't fail on them */
+
+ if ((actual_type != XA_WM_HINTS) ||
+ (nitems < (NumPropWMHintsElements - 1)) || (actual_format != 32)) {
+ if (prop != NULL) Xfree ((char *)prop);
+ return(NULL);
+ }
+ /* static copies not allowed in library, due to reentrancy constraint*/
+ if ((hints = (XWMHints *) Xcalloc (1, (unsigned) sizeof(XWMHints)))) {
+ hints->flags = prop->flags;
+ hints->input = (prop->input ? True : False);
+ hints->initial_state = cvtINT32toInt (prop->initialState);
+ hints->icon_pixmap = prop->iconPixmap;
+ hints->icon_window = prop->iconWindow;
+ hints->icon_x = cvtINT32toInt (prop->iconX);
+ hints->icon_y = cvtINT32toInt (prop->iconY);
+ hints->icon_mask = prop->iconMask;
+ if (nitems >= NumPropWMHintsElements)
+ hints->window_group = prop->windowGroup;
+ else
+ hints->window_group = 0;
+ }
+ Xfree ((char *)prop);
+ return(hints);
+}
+
+Status
+XGetZoomHints (dpy, w, zhints)
+ Display *dpy;
+ Window w;
+ XSizeHints *zhints;
+{
+ return (XGetSizeHints(dpy, w, zhints, XA_WM_ZOOM_HINTS));
+}
+
+Status
+XGetNormalHints (dpy, w, hints)
+ Display *dpy;
+ Window w;
+ XSizeHints *hints;
+{
+ return (XGetSizeHints(dpy, w, hints, XA_WM_NORMAL_HINTS));
+}
+
+
+/*
+ * XGetIconSizes reads the property
+ * ICONSIZE_ATOM type: ICONSIZE_ATOM format: 32
+ */
+
+Status XGetIconSizes (dpy, w, size_list, count)
+ Display *dpy;
+ Window w; /* typically, root */
+ XIconSize **size_list; /* RETURN */
+ int *count; /* RETURN number of items on the list */
+{
+ xPropIconSize *prop = NULL;
+ register xPropIconSize *pp;
+ register XIconSize *hp, *hints;
+ Atom actual_type;
+ int actual_format;
+ unsigned long leftover;
+ unsigned long nitems;
+ register int i;
+
+ if (XGetWindowProperty(dpy, w, XA_WM_ICON_SIZE, 0L, 60L,
+ False, XA_WM_ICON_SIZE, &actual_type, &actual_format,
+ &nitems, &leftover, (unsigned char **)&prop)
+ != Success) return (0);
+
+ pp = prop;
+
+ if ((actual_type != XA_WM_ICON_SIZE) ||
+ (nitems < NumPropIconSizeElements) ||
+ (nitems % NumPropIconSizeElements != 0) ||
+ (actual_format != 32)) {
+ if (prop != NULL) Xfree ((char *)prop);
+ return(0);
+ }
+
+ /* static copies not allowed in library, due to reentrancy constraint*/
+
+ nitems /= NumPropIconSizeElements;
+ if (! (hp = hints = (XIconSize *)
+ Xcalloc ((unsigned) nitems, (unsigned) sizeof(XIconSize)))) {
+ if (prop) Xfree ((char *) prop);
+ return 0;
+ }
+
+ /* march down array putting things into native form */
+ for (i = 0; i < nitems; i++) {
+ hp->min_width = cvtINT32toInt (pp->minWidth);
+ hp->min_height = cvtINT32toInt (pp->minHeight);
+ hp->max_width = cvtINT32toInt (pp->maxWidth);
+ hp->max_height = cvtINT32toInt (pp->maxHeight);
+ hp->width_inc = cvtINT32toInt (pp->widthInc);
+ hp->height_inc = cvtINT32toInt (pp->heightInc);
+ hp += 1;
+ pp += 1;
+ }
+ *count = nitems;
+ *size_list = hints;
+ Xfree ((char *)prop);
+ return(1);
+}
+
+
+Status XGetCommand (dpy, w, argvp, argcp)
+ Display *dpy;
+ Window w;
+ char ***argvp;
+ int *argcp;
+{
+ XTextProperty tp;
+ int argc;
+ char **argv;
+
+ if (!XGetTextProperty (dpy, w, &tp, XA_WM_COMMAND)) return 0;
+
+ if (tp.encoding != XA_STRING || tp.format != 8) {
+ if (tp.value) Xfree ((char *) tp.value);
+ return 0;
+ }
+
+
+ /*
+ * ignore final <NUL> if present since UNIX WM_COMMAND is nul-terminated
+ */
+ if (tp.nitems && (tp.value[tp.nitems - 1] == '\0')) tp.nitems--;
+
+
+ /*
+ * create a string list and return if successful
+ */
+ if (!XTextPropertyToStringList (&tp, &argv, &argc)) {
+ if (tp.value) Xfree ((char *) tp.value);
+ return (0);
+ }
+
+ if (tp.value) Xfree ((char *) tp.value);
+ *argvp = argv;
+ *argcp = argc;
+ return 1;
+}
+
+
+Status
+XGetTransientForHint(dpy, w, propWindow)
+ Display *dpy;
+ Window w;
+ Window *propWindow;
+{
+ Atom actual_type;
+ int actual_format;
+ unsigned long nitems;
+ unsigned long leftover;
+ Window *data = NULL;
+ if (XGetWindowProperty(dpy, w, XA_WM_TRANSIENT_FOR, 0L, 1L, False,
+ XA_WINDOW,
+ &actual_type,
+ &actual_format, &nitems, &leftover, (unsigned char **) &data)
+ != Success) {
+ *propWindow = None;
+ return (0);
+ }
+ if ( (actual_type == XA_WINDOW) && (actual_format == 32) &&
+ (nitems != 0) ) {
+ *propWindow = *data;
+ Xfree( (char *) data);
+ return (1);
+ }
+ *propWindow = None;
+ if (data) Xfree( (char *) data);
+ return(0);
+}
+
+Status
+XGetClassHint(dpy, w, classhint)
+ Display *dpy;
+ Window w;
+ XClassHint *classhint; /* RETURN */
+{
+ int len_name, len_class;
+
+ Atom actual_type;
+ int actual_format;
+ unsigned long nitems;
+ unsigned long leftover;
+ unsigned char *data = NULL;
+ if (XGetWindowProperty(dpy, w, XA_WM_CLASS, 0L, (long)BUFSIZ, False,
+ XA_STRING,
+ &actual_type,
+ &actual_format, &nitems, &leftover, &data) != Success)
+ return (0);
+
+ if ( (actual_type == XA_STRING) && (actual_format == 8) ) {
+ len_name = strlen((char *) data);
+ if (! (classhint->res_name = Xmalloc((unsigned) (len_name+1)))) {
+ Xfree((char *) data);
+ return (0);
+ }
+ strcpy(classhint->res_name, (char *) data);
+ if (len_name == nitems) len_name--;
+ len_class = strlen((char *) (data+len_name+1));
+ if (! (classhint->res_class = Xmalloc((unsigned) (len_class+1)))) {
+ Xfree(classhint->res_name);
+ classhint->res_name = (char *) NULL;
+ Xfree((char *) data);
+ return (0);
+ }
+ strcpy(classhint->res_class, (char *) (data+len_name+1));
+ Xfree( (char *) data);
+ return(1);
+ }
+ if (data) Xfree( (char *) data);
+ return(0);
+}
diff --git a/src/GetIFocus.c b/src/GetIFocus.c
new file mode 100644
index 00000000..7e2ca86c
--- /dev/null
+++ b/src/GetIFocus.c
@@ -0,0 +1,47 @@
+/* $Xorg: GetIFocus.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+XGetInputFocus(dpy, focus, revert_to)
+ register Display *dpy;
+ Window *focus;
+ int *revert_to;
+{
+ xGetInputFocusReply rep;
+ register xReq *req;
+ LockDisplay(dpy);
+ GetEmptyReq(GetInputFocus, req);
+ (void) _XReply (dpy, (xReply *)&rep, 0, xTrue);
+ *focus = rep.focus;
+ *revert_to = rep.revertTo;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/GetImage.c b/src/GetImage.c
new file mode 100644
index 00000000..ab665d81
--- /dev/null
+++ b/src/GetImage.c
@@ -0,0 +1,122 @@
+/* $Xorg: GetImage.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+#include <X11/Xutil.h> /* for XDestroyImage */
+
+#define ROUNDUP(nbytes, pad) (((((nbytes) - 1) + (pad)) / (pad)) * (pad))
+
+static unsigned int Ones(mask) /* HACKMEM 169 */
+ unsigned long mask;
+{
+ register unsigned long y;
+
+ y = (mask >> 1) &033333333333;
+ y = mask - y - ((y >>1) & 033333333333);
+ return ((unsigned int) (((y + (y >> 3)) & 030707070707) % 077));
+}
+
+XImage *XGetImage (dpy, d, x, y, width, height, plane_mask, format)
+ register Display *dpy;
+ Drawable d;
+ int x, y;
+ unsigned int width, height;
+ unsigned long plane_mask;
+ int format; /* either XYPixmap or ZPixmap */
+{
+ xGetImageReply rep;
+ register xGetImageReq *req;
+ char *data;
+ long nbytes;
+ XImage *image;
+ LockDisplay(dpy);
+ GetReq (GetImage, req);
+ /*
+ * first set up the standard stuff in the request
+ */
+ req->drawable = d;
+ req->x = x;
+ req->y = y;
+ req->width = width;
+ req->height = height;
+ req->planeMask = plane_mask;
+ req->format = format;
+
+ if (_XReply (dpy, (xReply *) &rep, 0, xFalse) == 0 ||
+ rep.length == 0) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XImage *)NULL;
+ }
+
+ nbytes = (long)rep.length << 2;
+ data = (char *) Xmalloc((unsigned) nbytes);
+ if (! data) {
+ _XEatData(dpy, (unsigned long) nbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XImage *) NULL;
+ }
+ _XReadPad (dpy, data, nbytes);
+ if (format == XYPixmap)
+ image = XCreateImage(dpy, _XVIDtoVisual(dpy, rep.visual),
+ Ones (plane_mask &
+ (((unsigned long)0xFFFFFFFF) >> (32 - rep.depth))),
+ format, 0, data, width, height, dpy->bitmap_pad, 0);
+ else /* format == ZPixmap */
+ image = XCreateImage (dpy, _XVIDtoVisual(dpy, rep.visual),
+ rep.depth, ZPixmap, 0, data, width, height,
+ _XGetScanlinePad(dpy, (int) rep.depth), 0);
+
+ if (!image)
+ Xfree(data);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (image);
+}
+
+XImage *XGetSubImage(dpy, d, x, y, width, height, plane_mask, format,
+ dest_image, dest_x, dest_y)
+ register Display *dpy;
+ Drawable d;
+ int x, y;
+ unsigned int width, height;
+ unsigned long plane_mask;
+ int format; /* either XYPixmap or ZPixmap */
+ XImage *dest_image;
+ int dest_x, dest_y;
+{
+ XImage *temp_image;
+ temp_image = XGetImage(dpy, d, x, y, width, height,
+ plane_mask, format);
+ if (!temp_image)
+ return (XImage *)NULL;
+ _XSetImage(temp_image, dest_image, dest_x, dest_y);
+ XDestroyImage(temp_image);
+ return (dest_image);
+}
diff --git a/src/GetKCnt.c b/src/GetKCnt.c
new file mode 100644
index 00000000..d8fa69c9
--- /dev/null
+++ b/src/GetKCnt.c
@@ -0,0 +1,53 @@
+/* $Xorg: GetKCnt.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+XGetKeyboardControl (dpy, state)
+ register Display *dpy;
+ register XKeyboardState *state;
+ {
+ xGetKeyboardControlReply rep;
+ register xReq *req;
+ LockDisplay(dpy);
+ GetEmptyReq (GetKeyboardControl, req);
+ (void) _XReply (dpy, (xReply *) &rep,
+ (SIZEOF(xGetKeyboardControlReply) - SIZEOF(xReply)) >> 2, xTrue);
+
+ state->key_click_percent = rep.keyClickPercent;
+ state->bell_percent = rep.bellPercent;
+ state->bell_pitch = rep.bellPitch;
+ state->bell_duration = rep.bellDuration;
+ state->led_mask = rep.ledMask;
+ state->global_auto_repeat = rep.globalAutoRepeat;
+ memcpy (state->auto_repeats, rep.map, sizeof state->auto_repeats);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+ }
+
diff --git a/src/GetMoEv.c b/src/GetMoEv.c
new file mode 100644
index 00000000..1bead38a
--- /dev/null
+++ b/src/GetMoEv.c
@@ -0,0 +1,83 @@
+/* $Xorg: GetMoEv.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+XTimeCoord *XGetMotionEvents(dpy, w, start, stop, nEvents)
+ register Display *dpy;
+ Time start, stop;
+ Window w;
+ int *nEvents; /* RETURN */
+{
+ xGetMotionEventsReply rep;
+ register xGetMotionEventsReq *req;
+ XTimeCoord *tc = NULL;
+ long nbytes;
+ LockDisplay(dpy);
+ GetReq(GetMotionEvents, req);
+ req->window = w;
+/* XXX is this right for all machines? */
+ req->start = start;
+ req->stop = stop;
+ if (!_XReply (dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (NULL);
+ }
+
+ if (rep.nEvents) {
+ if (! (tc = (XTimeCoord *)
+ Xmalloc( (unsigned)
+ (nbytes = (long) rep.nEvents * sizeof(XTimeCoord))))) {
+ _XEatData (dpy, (unsigned long) nbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (NULL);
+ }
+ }
+
+ *nEvents = rep.nEvents;
+ nbytes = SIZEOF (xTimecoord);
+ {
+ register XTimeCoord *tcptr;
+ register int i;
+ xTimecoord xtc;
+
+ for (i = rep.nEvents, tcptr = tc; i > 0; i--, tcptr++) {
+ _XRead (dpy, (char *) &xtc, nbytes);
+ tcptr->time = xtc.time;
+ tcptr->x = cvtINT16toShort (xtc.x);
+ tcptr->y = cvtINT16toShort (xtc.y);
+ }
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (tc);
+}
+
diff --git a/src/GetNrmHint.c b/src/GetNrmHint.c
new file mode 100644
index 00000000..741d1531
--- /dev/null
+++ b/src/GetNrmHint.c
@@ -0,0 +1,125 @@
+/* $Xorg: GetNrmHint.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/***********************************************************
+Copyright 1988 by Wyse Technology, Inc., San Jose, Ca,
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL AND WYSE DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL DIGITAL OR WYSE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
+USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+PERFORMANCE OF THIS SOFTWARE.
+
+******************************************************************/
+
+/*
+
+Copyright 1987, 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+
+#include <X11/Xlibint.h>
+#include <X11/Xatom.h>
+#include "Xatomtype.h"
+#include <X11/Xutil.h>
+#include <stdio.h>
+
+Status XGetWMSizeHints (dpy, w, hints, supplied, property)
+ Display *dpy;
+ Window w;
+ XSizeHints *hints;
+ long *supplied;
+ Atom property;
+{
+ xPropSizeHints *prop = NULL;
+ Atom actual_type;
+ int actual_format;
+ unsigned long leftover;
+ unsigned long nitems;
+
+ if (XGetWindowProperty (dpy, w, property, 0L,
+ (long)NumPropSizeElements,
+ False, XA_WM_SIZE_HINTS, &actual_type,
+ &actual_format, &nitems, &leftover,
+ (unsigned char **)&prop)
+ != Success)
+ return False;
+
+ if ((actual_type != XA_WM_SIZE_HINTS) ||
+ (nitems < OldNumPropSizeElements) || (actual_format != 32)) {
+ if (prop != NULL) Xfree ((char *)prop);
+ return False;
+ }
+
+ hints->flags = prop->flags;
+ /* XSizeHints misdeclares these as int instead of long */
+ hints->x = cvtINT32toInt (prop->x);
+ hints->y = cvtINT32toInt (prop->y);
+ hints->width = cvtINT32toInt (prop->width);
+ hints->height = cvtINT32toInt (prop->height);
+ hints->min_width = cvtINT32toInt (prop->minWidth);
+ hints->min_height = cvtINT32toInt (prop->minHeight);
+ hints->max_width = cvtINT32toInt (prop->maxWidth);
+ hints->max_height = cvtINT32toInt (prop->maxHeight);
+ hints->width_inc = cvtINT32toInt (prop->widthInc);
+ hints->height_inc = cvtINT32toInt (prop->heightInc);
+ hints->min_aspect.x = cvtINT32toInt (prop->minAspectX);
+ hints->min_aspect.y = cvtINT32toInt (prop->minAspectY);
+ hints->max_aspect.x = cvtINT32toInt (prop->maxAspectX);
+ hints->max_aspect.y = cvtINT32toInt (prop->maxAspectY);
+
+ *supplied = (USPosition | USSize | PAllHints);
+ if (nitems >= NumPropSizeElements) {
+ hints->base_width= cvtINT32toInt (prop->baseWidth);
+ hints->base_height= cvtINT32toInt (prop->baseHeight);
+ hints->win_gravity= cvtINT32toInt (prop->winGravity);
+ *supplied |= (PBaseSize | PWinGravity);
+ }
+ hints->flags &= (*supplied); /* get rid of unwanted bits */
+ Xfree((char *)prop);
+ return True;
+}
+
+
+Status XGetWMNormalHints (dpy, w, hints, supplied)
+ Display *dpy;
+ Window w;
+ XSizeHints *hints;
+ long *supplied;
+{
+ return (XGetWMSizeHints (dpy, w, hints, supplied, XA_WM_NORMAL_HINTS));
+}
diff --git a/src/GetPCnt.c b/src/GetPCnt.c
new file mode 100644
index 00000000..54b84270
--- /dev/null
+++ b/src/GetPCnt.c
@@ -0,0 +1,49 @@
+/* $Xorg: GetPCnt.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+XGetPointerControl(dpy, accel_numer, accel_denom, threshold)
+ register Display *dpy;
+ /* the following are return only vars */
+ int *accel_numer, *accel_denom;
+ int *threshold;
+{
+ xGetPointerControlReply rep;
+ xReq *req;
+ LockDisplay(dpy);
+ GetEmptyReq(GetPointerControl, req);
+ (void) _XReply (dpy, (xReply *)&rep, 0, xTrue);
+ *accel_numer = rep.accelNumerator;
+ *accel_denom = rep.accelDenominator;
+ *threshold = rep.threshold;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/GetPntMap.c b/src/GetPntMap.c
new file mode 100644
index 00000000..9af3a57c
--- /dev/null
+++ b/src/GetPntMap.c
@@ -0,0 +1,127 @@
+/* $Xorg: GetPntMap.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+#ifdef MIN /* some systems define this in <sys/param.h> */
+#undef MIN
+#endif
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+
+int XGetPointerMapping (dpy, map, nmaps)
+ register Display *dpy;
+ unsigned char *map; /* RETURN */
+ int nmaps;
+
+{
+ unsigned char mapping[256]; /* known fixed size */
+ long nbytes, remainder = 0;
+ xGetPointerMappingReply rep;
+ register xReq *req;
+
+ LockDisplay(dpy);
+ GetEmptyReq(GetPointerMapping, req);
+ if (! _XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+ }
+
+ nbytes = (long)rep.length << 2;
+
+ if (nbytes > sizeof mapping) {
+ remainder = nbytes - sizeof mapping;
+ nbytes = sizeof mapping;
+ }
+ _XRead (dpy, (char *)mapping, nbytes);
+ /* don't return more data than the user asked for. */
+ if (rep.nElts) {
+ memcpy ((char *) map, (char *) mapping,
+ MIN((int)rep.nElts, nmaps) );
+ }
+
+ if (remainder)
+ _XEatData(dpy, (unsigned long)remainder);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return ((int) rep.nElts);
+}
+
+#if NeedFunctionPrototypes
+KeySym *XGetKeyboardMapping (Display *dpy,
+#if NeedWidePrototypes
+ unsigned int first_keycode,
+#else
+ KeyCode first_keycode,
+#endif
+ int count,
+ int *keysyms_per_keycode)
+#else
+KeySym *XGetKeyboardMapping (dpy, first_keycode, count, keysyms_per_keycode)
+ register Display *dpy;
+ KeyCode first_keycode;
+ int count;
+ int *keysyms_per_keycode; /* RETURN */
+#endif
+{
+ long nbytes;
+ unsigned long nkeysyms;
+ register KeySym *mapping = NULL;
+ xGetKeyboardMappingReply rep;
+ register xGetKeyboardMappingReq *req;
+
+ LockDisplay(dpy);
+ GetReq(GetKeyboardMapping, req);
+ req->firstKeyCode = first_keycode;
+ req->count = count;
+ if (! _XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (KeySym *) NULL;
+ }
+
+ nkeysyms = (unsigned long) rep.length;
+ if (nkeysyms > 0) {
+ nbytes = nkeysyms * sizeof (KeySym);
+ mapping = (KeySym *) Xmalloc ((unsigned) nbytes);
+ nbytes = nkeysyms << 2;
+ if (! mapping) {
+ _XEatData(dpy, (unsigned long) nbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (KeySym *) NULL;
+ }
+ _XRead32 (dpy, (char *) mapping, nbytes);
+ }
+ *keysyms_per_keycode = rep.keySymsPerKeyCode;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (mapping);
+}
+
diff --git a/src/GetProp.c b/src/GetProp.c
new file mode 100644
index 00000000..ac8ef1c5
--- /dev/null
+++ b/src/GetProp.c
@@ -0,0 +1,129 @@
+/* $Xorg: GetProp.c,v 1.5 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+int
+XGetWindowProperty(dpy, w, property, offset, length, delete,
+ req_type, actual_type, actual_format, nitems, bytesafter, prop)
+ register Display *dpy;
+ Window w;
+ Atom property;
+ Bool delete;
+ Atom req_type;
+ Atom *actual_type; /* RETURN */
+ int *actual_format; /* RETURN 8, 16, or 32 */
+ long offset, length;
+ unsigned long *nitems; /* RETURN # of 8-, 16-, or 32-bit entities */
+ unsigned long *bytesafter; /* RETURN */
+ unsigned char **prop; /* RETURN */
+{
+ xGetPropertyReply reply;
+ register xGetPropertyReq *req;
+ xError error;
+
+ LockDisplay(dpy);
+ GetReq (GetProperty, req);
+ req->window = w;
+ req->property = property;
+ req->type = req_type;
+ req->delete = delete;
+ req->longOffset = offset;
+ req->longLength = length;
+ error.sequenceNumber = dpy->request;
+
+ if (!_XReply (dpy, (xReply *) &reply, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (1); /* not Success */
+ }
+
+ *prop = (unsigned char *) NULL;
+ if (reply.propertyType != None) {
+ long nbytes, netbytes;
+ switch (reply.format) {
+ /*
+ * One extra byte is malloced than is needed to contain the property
+ * data, but this last byte is null terminated and convenient for
+ * returning string properties, so the client doesn't then have to
+ * recopy the string to make it null terminated.
+ */
+ case 8:
+ nbytes = netbytes = reply.nItems;
+ if ((*prop = (unsigned char *) Xmalloc ((unsigned)nbytes + 1)))
+ _XReadPad (dpy, (char *) *prop, netbytes);
+ break;
+
+ case 16:
+ nbytes = reply.nItems * sizeof (short);
+ netbytes = reply.nItems << 1;
+ if ((*prop = (unsigned char *) Xmalloc ((unsigned)nbytes + 1)))
+ _XRead16Pad (dpy, (short *) *prop, netbytes);
+ break;
+
+ case 32:
+ nbytes = reply.nItems * sizeof (long);
+ netbytes = reply.nItems << 2;
+ if ((*prop = (unsigned char *) Xmalloc ((unsigned)nbytes + 1)))
+ _XRead32 (dpy, (long *) *prop, netbytes);
+ break;
+
+ default:
+ /*
+ * This part of the code should never be reached. If it is,
+ * the server sent back a property with an invalid format.
+ * This is a BadImplementation error.
+ */
+ {
+ /* sequence number stored above */
+ error.type = X_Error;
+ error.majorCode = X_GetProperty;
+ error.minorCode = 0;
+ error.errorCode = BadImplementation;
+ _XError(dpy, &error);
+ }
+ netbytes = 0L;
+ break;
+ }
+ if (! *prop) {
+ _XEatData(dpy, (unsigned long) netbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(BadAlloc); /* not Success */
+ }
+ (*prop)[nbytes] = '\0';
+ }
+ *actual_type = reply.propertyType;
+ *actual_format = reply.format;
+ *nitems = reply.nItems;
+ *bytesafter = reply.bytesAfter;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(Success);
+}
+
diff --git a/src/GetRGBCMap.c b/src/GetRGBCMap.c
new file mode 100644
index 00000000..bde36215
--- /dev/null
+++ b/src/GetRGBCMap.c
@@ -0,0 +1,133 @@
+/* $Xorg: GetRGBCMap.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+#include "Xatomtype.h"
+#include <X11/Xatom.h>
+
+Status XGetRGBColormaps (dpy, w, stdcmap, count, property)
+ Display *dpy;
+ Window w;
+ XStandardColormap **stdcmap; /* RETURN */
+ int *count; /* RETURN */
+ Atom property; /* XA_RGB_BEST_MAP, etc. */
+{
+ register int i; /* iterator variable */
+ xPropStandardColormap *data = NULL; /* data read in from prop */
+ Atom actual_type; /* how the prop was actually stored */
+ int actual_format; /* ditto */
+ unsigned long leftover; /* how much was left over */
+ unsigned long nitems; /* number of 32bits read */
+ int ncmaps; /* number of structs this makes */
+ Bool old_style = False; /* if was too short */
+ VisualID def_visual = None; /* visual to use if prop too short */
+ XStandardColormap *cmaps; /* return value */
+
+
+ if (XGetWindowProperty (dpy, w, property, 0L, 1000000L, False,
+ XA_RGB_COLOR_MAP, &actual_type, &actual_format,
+ &nitems, &leftover, (unsigned char **)&data)
+ != Success)
+ return False;
+
+ /* if wrong type or format, or too small for us, then punt */
+ if ((actual_type != XA_RGB_COLOR_MAP) || (actual_format != 32) ||
+ (nitems < OldNumPropStandardColormapElements)) {
+ if (data) Xfree ((char *) data);
+ return False;
+ }
+
+ /*
+ * See how many properties were found; if pre-ICCCM then assume
+ * default visual and a kill id of 1.
+ */
+ if (nitems < NumPropStandardColormapElements) {
+ ncmaps = 1;
+ old_style = True;
+ if (nitems < (NumPropStandardColormapElements - 1)) {
+ Screen *sp = _XScreenOfWindow (dpy, w);
+
+ if (!sp) {
+ if (data) Xfree ((char *) data);
+ return False;
+ }
+ def_visual = sp->root_visual->visualid;
+ }
+ } else {
+ /*
+ * make sure we have an integral number of colormaps
+ */
+ ncmaps = (nitems / NumPropStandardColormapElements);
+ if ((((unsigned long) ncmaps) * NumPropStandardColormapElements) !=
+ nitems) {
+ if (data) Xfree ((char *) data);
+ return False;
+ }
+ }
+
+
+ /*
+ * allocate array
+ */
+ cmaps = (XStandardColormap *) Xmalloc (ncmaps *
+ sizeof (XStandardColormap));
+ if (!cmaps) {
+ if (data) Xfree ((char *) data);
+ return False;
+ }
+
+
+ /*
+ * and fill it in, handling compatibility with pre-ICCCM short stdcmaps
+ */
+ {
+ register XStandardColormap *map;
+ register xPropStandardColormap *prop;
+
+ for (i = ncmaps, map = cmaps, prop = data; i > 0; i--, map++, prop++) {
+ map->colormap = prop->colormap;
+ map->red_max = prop->red_max;
+ map->red_mult = prop->red_mult;
+ map->green_max = prop->green_max;
+ map->green_mult = prop->green_mult;
+ map->blue_max = prop->blue_max;
+ map->blue_mult = prop->blue_mult;
+ map->base_pixel = prop->base_pixel;
+ map->visualid = (def_visual ? def_visual : prop->visualid);
+ map->killid = (old_style ? None : prop->killid);
+ }
+ }
+ Xfree ((char *) data);
+ *stdcmap = cmaps;
+ *count = ncmaps;
+ return True;
+}
+
diff --git a/src/GetSOwner.c b/src/GetSOwner.c
new file mode 100644
index 00000000..b9bacdfc
--- /dev/null
+++ b/src/GetSOwner.c
@@ -0,0 +1,44 @@
+/* $Xorg: GetSOwner.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+Window XGetSelectionOwner(dpy, selection)
+register Display *dpy;
+Atom selection;
+{
+ xGetSelectionOwnerReply rep;
+ register xResourceReq *req;
+ LockDisplay(dpy);
+ GetResReq(GetSelectionOwner, selection, req);
+
+ if (_XReply(dpy, (xReply *)&rep, 0, xTrue) == 0) rep.owner = None;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(rep.owner);
+}
diff --git a/src/GetSSaver.c b/src/GetSSaver.c
new file mode 100644
index 00000000..60a7ef08
--- /dev/null
+++ b/src/GetSSaver.c
@@ -0,0 +1,52 @@
+/* $Xorg: GetSSaver.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+XGetScreenSaver(dpy, timeout, interval, prefer_blanking, allow_exp)
+ register Display *dpy;
+ /* the following are return only vars */
+ int *timeout, *interval;
+ int *prefer_blanking, *allow_exp; /*boolean */
+
+{
+ xGetScreenSaverReply rep;
+ register xReq *req;
+ LockDisplay(dpy);
+ GetEmptyReq(GetScreenSaver, req);
+
+ (void) _XReply (dpy, (xReply *)&rep, 0, xTrue);
+ *timeout = rep.timeout;
+ *interval = rep.interval;
+ *prefer_blanking = rep.preferBlanking;
+ *allow_exp = rep.allowExposures;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/GetStCmap.c b/src/GetStCmap.c
new file mode 100644
index 00000000..0674bcb8
--- /dev/null
+++ b/src/GetStCmap.c
@@ -0,0 +1,115 @@
+/* $Xorg: GetStCmap.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+#include "Xatomtype.h"
+#include <X11/Xatom.h>
+
+/*
+ * WARNING
+ *
+ * This is a pre-ICCCM routine. It must not reference any of the new fields
+ * in the XStandardColormap structure.
+ */
+
+Status XGetStandardColormap (dpy, w, cmap, property)
+ Display *dpy;
+ Window w;
+ XStandardColormap *cmap;
+ Atom property; /* XA_RGB_BEST_MAP, etc. */
+{
+ Status stat; /* return value */
+ XStandardColormap *stdcmaps; /* will get malloced value */
+ int nstdcmaps; /* count of above */
+
+ stat = XGetRGBColormaps (dpy, w, &stdcmaps, &nstdcmaps, property);
+ if (stat) {
+ XStandardColormap *use;
+
+ if (nstdcmaps > 1) {
+ VisualID vid;
+ Screen *sp = _XScreenOfWindow (dpy, w);
+ int i;
+
+ if (!sp) {
+ if (stdcmaps) Xfree ((char *) stdcmaps);
+ return False;
+ }
+ vid = sp->root_visual->visualid;
+
+ for (i = 0; i < nstdcmaps; i++) {
+ if (stdcmaps[i].visualid == vid) break;
+ }
+
+ if (i == nstdcmaps) { /* not found */
+ Xfree ((char *) stdcmaps);
+ return False;
+ }
+ use = &stdcmaps[i];
+ } else {
+ use = stdcmaps;
+ }
+
+ /*
+ * assign only those fields which were in the pre-ICCCM version
+ */
+ cmap->colormap = use->colormap;
+ cmap->red_max = use->red_max;
+ cmap->red_mult = use->red_mult;
+ cmap->green_max = use->green_max;
+ cmap->green_mult = use->green_mult;
+ cmap->blue_max = use->blue_max;
+ cmap->blue_mult = use->blue_mult;
+ cmap->base_pixel = use->base_pixel;
+
+ Xfree ((char *) stdcmaps); /* don't need alloced memory */
+ }
+ return stat;
+}
diff --git a/src/GetTxtProp.c b/src/GetTxtProp.c
new file mode 100644
index 00000000..bbd62851
--- /dev/null
+++ b/src/GetTxtProp.c
@@ -0,0 +1,111 @@
+/* $Xorg: GetTxtProp.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/***********************************************************
+Copyright 1988 by Wyse Technology, Inc., San Jose, Ca.,
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name Wyse not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+WYSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/*
+
+Copyright 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#include <X11/Xlibint.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+#include <X11/Xos.h>
+#include <stdio.h>
+
+Status XGetTextProperty (display, window, tp, property)
+ Display *display;
+ Window window;
+ XTextProperty *tp;
+ Atom property;
+{
+ Atom actual_type;
+ int actual_format = 0;
+ unsigned long nitems = 0L, leftover = 0L;
+ unsigned char *prop = NULL;
+
+ if (XGetWindowProperty (display, window, property, 0L, 1000000L, False,
+ AnyPropertyType, &actual_type, &actual_format,
+ &nitems, &leftover, &prop) == Success &&
+ actual_type != None) {
+ /* okay, fill it in */
+ tp->value = prop;
+ tp->encoding = actual_type;
+ tp->format = actual_format;
+ tp->nitems = nitems;
+ return True;
+ }
+
+ tp->value = NULL;
+ tp->encoding = None;
+ tp->format = 0;
+ tp->nitems = 0;
+ return False;
+}
+
+Status XGetWMName (dpy, w, tp)
+ Display *dpy;
+ Window w;
+ XTextProperty *tp;
+{
+ return (XGetTextProperty (dpy, w, tp, XA_WM_NAME));
+}
+
+Status XGetWMIconName (dpy, w, tp)
+ Display *dpy;
+ Window w;
+ XTextProperty *tp;
+{
+ return (XGetTextProperty (dpy, w, tp, XA_WM_ICON_NAME));
+}
+
+Status XGetWMClientMachine (dpy, w, tp)
+ Display *dpy;
+ Window w;
+ XTextProperty *tp;
+{
+ return (XGetTextProperty (dpy, w, tp, XA_WM_CLIENT_MACHINE));
+}
+
diff --git a/src/GetWAttrs.c b/src/GetWAttrs.c
new file mode 100644
index 00000000..7856b6f0
--- /dev/null
+++ b/src/GetWAttrs.c
@@ -0,0 +1,144 @@
+/* $Xorg: GetWAttrs.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+typedef struct _WAttrsState {
+ unsigned long attr_seq;
+ unsigned long geom_seq;
+ XWindowAttributes *attr;
+} _XWAttrsState;
+
+static Bool
+_XWAttrsHandler(dpy, rep, buf, len, data)
+ register Display *dpy;
+ register xReply *rep;
+ char *buf;
+ int len;
+ XPointer data;
+{
+ register _XWAttrsState *state;
+ xGetWindowAttributesReply replbuf;
+ register xGetWindowAttributesReply *repl;
+ register XWindowAttributes *attr;
+
+ state = (_XWAttrsState *)data;
+ if (dpy->last_request_read != state->attr_seq) {
+ if (dpy->last_request_read == state->geom_seq &&
+ !state->attr &&
+ rep->generic.type == X_Error &&
+ rep->error.errorCode == BadDrawable)
+ return True;
+ return False;
+ }
+ if (rep->generic.type == X_Error) {
+ state->attr = (XWindowAttributes *)NULL;
+ return False;
+ }
+ repl = (xGetWindowAttributesReply *)
+ _XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len,
+ (SIZEOF(xGetWindowAttributesReply) - SIZEOF(xReply)) >> 2,
+ True);
+ attr = state->attr;
+ attr->class = repl->class;
+ attr->bit_gravity = repl->bitGravity;
+ attr->win_gravity = repl->winGravity;
+ attr->backing_store = repl->backingStore;
+ attr->backing_planes = repl->backingBitPlanes;
+ attr->backing_pixel = repl->backingPixel;
+ attr->save_under = repl->saveUnder;
+ attr->colormap = repl->colormap;
+ attr->map_installed = repl->mapInstalled;
+ attr->map_state = repl->mapState;
+ attr->all_event_masks = repl->allEventMasks;
+ attr->your_event_mask = repl->yourEventMask;
+ attr->do_not_propagate_mask = repl->doNotPropagateMask;
+ attr->override_redirect = repl->override;
+ attr->visual = _XVIDtoVisual (dpy, repl->visualID);
+ return True;
+}
+
+Status XGetWindowAttributes(dpy, w, attr)
+ register Display *dpy;
+ Window w;
+ XWindowAttributes *attr;
+{
+ xGetGeometryReply rep;
+ register xResourceReq *req;
+ register int i;
+ register Screen *sp;
+ _XAsyncHandler async;
+ _XWAttrsState async_state;
+
+ LockDisplay(dpy);
+ GetResReq(GetWindowAttributes, w, req);
+
+ async_state.attr_seq = dpy->request;
+ async_state.geom_seq = 0;
+ async_state.attr = attr;
+ async.next = dpy->async_handlers;
+ async.handler = _XWAttrsHandler;
+ async.data = (XPointer)&async_state;
+ dpy->async_handlers = &async;
+
+ GetResReq(GetGeometry, w, req);
+
+ async_state.geom_seq = dpy->request;
+
+ if (!_XReply (dpy, (xReply *)&rep, 0, xTrue)) {
+ DeqAsyncHandler(dpy, &async);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (0);
+ }
+ DeqAsyncHandler(dpy, &async);
+ if (!async_state.attr) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (0);
+ }
+ attr->x = cvtINT16toInt (rep.x);
+ attr->y = cvtINT16toInt (rep.y);
+ attr->width = rep.width;
+ attr->height = rep.height;
+ attr->border_width = rep.borderWidth;
+ attr->depth = rep.depth;
+ attr->root = rep.root;
+ /* find correct screen so that applications find it easier.... */
+ for (i = 0; i < dpy->nscreens; i++) {
+ sp = &dpy->screens[i];
+ if (sp->root == attr->root) {
+ attr->screen = sp;
+ break;
+ }
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(1);
+}
+
diff --git a/src/GetWMCMapW.c b/src/GetWMCMapW.c
new file mode 100644
index 00000000..6c56a136
--- /dev/null
+++ b/src/GetWMCMapW.c
@@ -0,0 +1,85 @@
+/* $Xorg: GetWMCMapW.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#include "Xlibint.h"
+#include <X11/Xatom.h>
+#include <stdio.h>
+
+Status XGetWMColormapWindows (dpy, w, colormapWindows, countReturn)
+ Display *dpy;
+ Window w;
+ Window **colormapWindows;
+ int *countReturn;
+{
+ Atom *data = NULL;
+ Atom actual_type;
+ Atom prop;
+ int actual_format;
+ unsigned long leftover, nitems;
+
+ prop = XInternAtom(dpy, "WM_COLORMAP_WINDOWS", False);
+ if (prop == None) return False;
+
+ /* get the property */
+ if (XGetWindowProperty (dpy, w, prop,
+ 0L, 1000000L, False,
+ XA_WINDOW, &actual_type, &actual_format,
+ &nitems, &leftover, (unsigned char **) &data)
+ != Success)
+ return False;
+
+ if (actual_type != XA_WINDOW || actual_format != 32) {
+ if (data) Xfree ((char *) data);
+ return False;
+ }
+
+ *colormapWindows = (Window *) data;
+ *countReturn = (int) nitems;
+ return True;
+}
diff --git a/src/GetWMProto.c b/src/GetWMProto.c
new file mode 100644
index 00000000..84e79b60
--- /dev/null
+++ b/src/GetWMProto.c
@@ -0,0 +1,85 @@
+/* $Xorg: GetWMProto.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#include "Xlibint.h"
+#include <X11/Xatom.h>
+#include <stdio.h>
+
+Status XGetWMProtocols (dpy, w, protocols, countReturn)
+ Display *dpy;
+ Window w;
+ Atom **protocols;
+ int *countReturn;
+{
+ Atom *data = NULL;
+ Atom actual_type;
+ Atom prop;
+ int actual_format;
+ unsigned long leftover, nitems;
+
+ prop = XInternAtom(dpy, "WM_PROTOCOLS", False);
+ if (prop == None) return False;
+
+ /* get the property */
+ if (XGetWindowProperty (dpy, w, prop,
+ 0L, 1000000L, False,
+ XA_ATOM, &actual_type, &actual_format,
+ &nitems, &leftover, (unsigned char **) &data)
+ != Success)
+ return False;
+
+ if (actual_type != XA_ATOM || actual_format != 32) {
+ if (data) Xfree ((char *) data);
+ return False;
+ }
+
+ *protocols = (Atom *) data;
+ *countReturn = (int) nitems;
+ return True;
+}
diff --git a/src/GrButton.c b/src/GrButton.c
new file mode 100644
index 00000000..f0a8ebfb
--- /dev/null
+++ b/src/GrButton.c
@@ -0,0 +1,57 @@
+/* $Xorg: GrButton.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XGrabButton(dpy, button, modifiers, grab_window, owner_events, event_mask,
+ pointer_mode, keyboard_mode, confine_to, curs)
+register Display *dpy;
+unsigned int modifiers; /* CARD16 */
+unsigned int button; /* CARD8 */
+Window grab_window;
+Bool owner_events;
+unsigned int event_mask; /* CARD16 */
+int pointer_mode, keyboard_mode;
+Window confine_to;
+Cursor curs;
+{
+ register xGrabButtonReq *req;
+ LockDisplay(dpy);
+ GetReq(GrabButton, req);
+ req->modifiers = modifiers;
+ req->button = button;
+ req->grabWindow = grab_window;
+ req->ownerEvents = owner_events;
+ req->eventMask = event_mask;
+ req->pointerMode = pointer_mode;
+ req->keyboardMode = keyboard_mode;
+ req->confineTo = confine_to;
+ req->cursor = curs;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/GrKey.c b/src/GrKey.c
new file mode 100644
index 00000000..4f339b75
--- /dev/null
+++ b/src/GrKey.c
@@ -0,0 +1,55 @@
+/* $Xorg: GrKey.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XGrabKey(dpy, key, modifiers, grab_window, owner_events,
+ pointer_mode, keyboard_mode)
+ register Display *dpy;
+ int key;
+ unsigned int modifiers;
+ Window grab_window;
+ Bool owner_events;
+ int pointer_mode, keyboard_mode;
+
+{
+ register xGrabKeyReq *req;
+ LockDisplay(dpy);
+ GetReq(GrabKey, req);
+ req->ownerEvents = owner_events;
+ req->grabWindow = grab_window;
+ req->modifiers = modifiers;
+ req->key = key;
+ req->pointerMode = pointer_mode;
+ req->keyboardMode = keyboard_mode;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+
+
diff --git a/src/GrKeybd.c b/src/GrKeybd.c
new file mode 100644
index 00000000..3f43f7ae
--- /dev/null
+++ b/src/GrKeybd.c
@@ -0,0 +1,56 @@
+/* $Xorg: GrKeybd.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+int XGrabKeyboard (dpy, window, ownerEvents, pointerMode, keyboardMode, time)
+ register Display *dpy;
+ Window window;
+ Bool ownerEvents;
+ int pointerMode, keyboardMode;
+ Time time;
+{
+ xGrabKeyboardReply rep;
+ register xGrabKeyboardReq *req;
+ register int status;
+ LockDisplay(dpy);
+ GetReq(GrabKeyboard, req);
+ req->grabWindow = window;
+ req->ownerEvents = ownerEvents;
+ req->pointerMode = pointerMode;
+ req->keyboardMode = keyboardMode;
+ req->time = time;
+
+ /* if we ever return, suppress the error */
+ if (_XReply (dpy, (xReply *) &rep, 0, xTrue) == 0)
+ rep.status = GrabSuccess;
+ status = rep.status;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (status);
+}
+
diff --git a/src/GrPointer.c b/src/GrPointer.c
new file mode 100644
index 00000000..544337a9
--- /dev/null
+++ b/src/GrPointer.c
@@ -0,0 +1,63 @@
+/* $Xorg: GrPointer.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+int XGrabPointer(dpy, grab_window, owner_events, event_mask, pointer_mode,
+ keyboard_mode, confine_to, curs, time)
+register Display *dpy;
+Window grab_window;
+Bool owner_events;
+unsigned int event_mask; /* CARD16 */
+int pointer_mode, keyboard_mode;
+Window confine_to;
+Cursor curs;
+Time time;
+{
+ xGrabPointerReply rep;
+ register xGrabPointerReq *req;
+ register int status;
+ LockDisplay(dpy);
+ GetReq(GrabPointer, req);
+ req->grabWindow = grab_window;
+ req->ownerEvents = owner_events;
+ req->eventMask = event_mask;
+ req->pointerMode = pointer_mode;
+ req->keyboardMode = keyboard_mode;
+ req->confineTo = confine_to;
+ req->cursor = curs;
+ req->time = time;
+
+ /* if we ever return, suppress the error */
+ if (_XReply (dpy, (xReply *) &rep, 0, xTrue) == 0)
+ rep.status = GrabSuccess;
+ status = rep.status;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (status);
+}
diff --git a/src/GrServer.c b/src/GrServer.c
new file mode 100644
index 00000000..9dfc04ac
--- /dev/null
+++ b/src/GrServer.c
@@ -0,0 +1,40 @@
+/* $Xorg: GrServer.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XGrabServer (dpy)
+register Display *dpy;
+{
+ register xReq *req;
+ LockDisplay(dpy);
+ GetEmptyReq(GrabServer, req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/Host.c b/src/Host.c
new file mode 100644
index 00000000..863ff8ef
--- /dev/null
+++ b/src/Host.c
@@ -0,0 +1,91 @@
+/* $Xorg: Host.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/* this might be rightly reguarded an os dependent file */
+
+#include "Xlibint.h"
+
+XAddHost (dpy, host)
+ register Display *dpy;
+ XHostAddress *host;
+ {
+ register xChangeHostsReq *req;
+ register int length = (host->length + 3) & ~0x3; /* round up */
+
+ LockDisplay(dpy);
+ GetReqExtra (ChangeHosts, length, req);
+ req->mode = HostInsert;
+ req->hostFamily = host->family;
+ req->hostLength = host->length;
+ memcpy((char *) NEXTPTR(req,xChangeHostsReq), host->address, host->length);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+ }
+
+XRemoveHost (dpy, host)
+ register Display *dpy;
+ XHostAddress *host;
+ {
+ register xChangeHostsReq *req;
+ register int length = (host->length + 3) & ~0x3; /* round up */
+
+ LockDisplay(dpy);
+ GetReqExtra (ChangeHosts, length, req);
+ req->mode = HostDelete;
+ req->hostFamily = host->family;
+ req->hostLength = host->length;
+ memcpy((char *) NEXTPTR(req,xChangeHostsReq), host->address, host->length);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+ }
+
+
+XAddHosts (dpy, hosts, n)
+ register Display *dpy;
+ XHostAddress *hosts;
+ int n;
+{
+ register int i;
+ for (i = 0; i < n; i++) {
+ (void) XAddHost(dpy, &hosts[i]);
+ }
+ return 1;
+}
+
+XRemoveHosts (dpy, hosts, n)
+ register Display *dpy;
+ XHostAddress *hosts;
+ int n;
+{
+ register int i;
+ for (i = 0; i < n; i++) {
+ (void) XRemoveHost(dpy, &hosts[i]);
+ }
+ return 1;
+}
diff --git a/src/Iconify.c b/src/Iconify.c
new file mode 100644
index 00000000..b67b6602
--- /dev/null
+++ b/src/Iconify.c
@@ -0,0 +1,84 @@
+/* $Xorg: Iconify.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1988 by Wyse Technology, Inc., San Jose, Ca.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name Wyse not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+WYSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/*
+
+Copyright 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#define NEED_EVENTS
+#include <X11/Xlibint.h>
+#include <X11/Xatom.h>
+#include <X11/Xos.h>
+#include <X11/Xutil.h>
+#include <stdio.h>
+
+/*
+ * This function instructs the window manager to change this window from
+ * NormalState to IconicState.
+ */
+Status XIconifyWindow (dpy, w, screen)
+ Display *dpy;
+ Window w;
+ int screen;
+{
+ XClientMessageEvent ev;
+ Window root = RootWindow (dpy, screen);
+ Atom prop;
+
+ prop = XInternAtom (dpy, "WM_CHANGE_STATE", False);
+ if (prop == None) return False;
+
+ ev.type = ClientMessage;
+ ev.window = w;
+ ev.message_type = prop;
+ ev.format = 32;
+ ev.data.l[0] = IconicState;
+ return (XSendEvent (dpy, root, False,
+ SubstructureRedirectMask|SubstructureNotifyMask,
+ (XEvent *)&ev));
+}
diff --git a/src/IfEvent.c b/src/IfEvent.c
new file mode 100644
index 00000000..975d77a1
--- /dev/null
+++ b/src/IfEvent.c
@@ -0,0 +1,72 @@
+/* $Xorg: IfEvent.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_EVENTS
+#include "Xlibint.h"
+
+/*
+ * Flush output and (wait for and) return the next event matching the
+ * predicate in the queue.
+ */
+
+XIfEvent (dpy, event, predicate, arg)
+ register Display *dpy;
+ Bool (*predicate)(
+#if NeedNestedPrototypes
+ Display* /* display */,
+ XEvent* /* event */,
+ char* /* arg */
+#endif
+ ); /* function to call */
+ register XEvent *event;
+ char *arg;
+{
+ register _XQEvent *qelt, *prev;
+ unsigned long qe_serial = 0;
+
+ LockDisplay(dpy);
+ prev = NULL;
+ while (1) {
+ for (qelt = prev ? prev->next : dpy->head;
+ qelt;
+ prev = qelt, qelt = qelt->next) {
+ if(qelt->qserial_num > qe_serial
+ && (*predicate)(dpy, &qelt->event, arg)) {
+ *event = qelt->event;
+ _XDeq(dpy, prev, qelt);
+ UnlockDisplay(dpy);
+ return 0;
+ }
+ }
+ if (prev)
+ qe_serial = prev->qserial_num;
+ _XReadEvents(dpy);
+ if (prev && prev->qserial_num != qe_serial)
+ /* another thread has snatched this event */
+ prev = NULL;
+ }
+}
diff --git a/src/ImText.c b/src/ImText.c
new file mode 100644
index 00000000..45f17983
--- /dev/null
+++ b/src/ImText.c
@@ -0,0 +1,109 @@
+/* $Xorg: ImText.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+#if NeedFunctionPrototypes
+XDrawImageString(
+ register Display *dpy,
+ Drawable d,
+ GC gc,
+ int x,
+ int y,
+ _Xconst char *string,
+ int length)
+#else
+XDrawImageString(dpy, d, gc, x, y, string, length)
+ register Display *dpy;
+ Drawable d;
+ GC gc;
+ int x, y;
+ char *string;
+ int length;
+#endif
+{
+ register xImageText8Req *req;
+ char *CharacterOffset = (char *)string;
+ int FirstTimeThrough = True;
+ int lastX = 0;
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+
+ while (length > 0)
+ {
+ int Unit;
+
+ if (length > 255) Unit = 255;
+ else Unit = length;
+
+ if (FirstTimeThrough)
+ {
+ FirstTimeThrough = False;
+ }
+ else
+ {
+ char buf[512];
+ char *ptr, *str;
+ xQueryTextExtentsReq *qreq;
+ xQueryTextExtentsReply rep;
+ int i;
+
+ GetReq(QueryTextExtents, qreq);
+ qreq->fid = gc->gid;
+ qreq->length += (510 + 3)>>2;
+ qreq->oddLength = 1;
+ str = CharacterOffset - 255;
+ for (ptr = buf, i = 255; --i >= 0; ) {
+ *ptr++ = 0;
+ *ptr++ = *str++;
+ }
+ Data (dpy, buf, 510);
+ if (!_XReply (dpy, (xReply *)&rep, 0, xTrue))
+ break;
+
+ x = lastX + cvtINT32toInt (rep.overallWidth);
+ }
+
+ GetReq (ImageText8, req);
+ req->length += (Unit + 3) >> 2;
+ req->nChars = Unit;
+ req->drawable = d;
+ req->gc = gc->gid;
+ req->y = y;
+
+ lastX = req->x = x;
+ Data (dpy, CharacterOffset, (long)Unit);
+ CharacterOffset += Unit;
+ length -= Unit;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+}
+
diff --git a/src/ImText16.c b/src/ImText16.c
new file mode 100644
index 00000000..fdc171ad
--- /dev/null
+++ b/src/ImText16.c
@@ -0,0 +1,111 @@
+/* $Xorg: ImText16.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+#if NeedFunctionPrototypes
+XDrawImageString16(
+ register Display *dpy,
+ Drawable d,
+ GC gc,
+ int x,
+ int y,
+ _Xconst XChar2b *string,
+ int length)
+#else
+XDrawImageString16(dpy, d, gc, x, y, string, length)
+ register Display *dpy;
+ Drawable d;
+ GC gc;
+ int x, y;
+ XChar2b *string;
+ int length;
+#endif
+{
+ register xImageText16Req *req;
+ XChar2b *CharacterOffset = (XChar2b *)string;
+ int FirstTimeThrough = True;
+ int lastX = 0;
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+
+ while (length > 0)
+ {
+ int Unit, Datalength;
+
+ if (length > 255) Unit = 255;
+ else Unit = length;
+
+ if (FirstTimeThrough)
+ {
+ FirstTimeThrough = False;
+ }
+ else
+ {
+ char buf[512];
+ xQueryTextExtentsReq *qreq;
+ xQueryTextExtentsReply rep;
+ unsigned char *ptr;
+ XChar2b *str;
+ int i;
+
+ GetReq(QueryTextExtents, qreq);
+ qreq->fid = gc->gid;
+ qreq->length += (510 + 3)>>2;
+ qreq->oddLength = 1;
+ str = CharacterOffset - 255;
+ for (ptr = (unsigned char *)buf, i = 255; --i >= 0; str++) {
+ *ptr++ = str->byte1;
+ *ptr++ = str->byte2;
+ }
+ Data (dpy, buf, 510);
+ if (!_XReply (dpy, (xReply *)&rep, 0, xTrue))
+ break;
+
+ x = lastX + cvtINT32toInt (rep.overallWidth);
+ }
+
+ GetReq (ImageText16, req);
+ req->length += ((Unit << 1) + 3) >> 2;
+ req->nChars = Unit;
+ req->drawable = d;
+ req->gc = gc->gid;
+ req->y = y;
+
+ lastX = req->x = x;
+ Datalength = Unit << 1;
+ Data (dpy, (char *)CharacterOffset, (long)Datalength);
+ CharacterOffset += Unit;
+ length -= Unit;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+}
+
diff --git a/src/ImUtil.c b/src/ImUtil.c
new file mode 100644
index 00000000..b358e511
--- /dev/null
+++ b/src/ImUtil.c
@@ -0,0 +1,1016 @@
+/* $Xorg: ImUtil.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+#include <stdio.h>
+
+#ifdef __STDC__
+#define Const const
+#else
+#define Const /**/
+#endif
+
+#if NeedFunctionPrototypes
+static int _XDestroyImage(XImage *);
+static unsigned long _XGetPixel(XImage *, int, int);
+static unsigned long _XGetPixel1(XImage *, int, int);
+static unsigned long _XGetPixel8(XImage *, int, int);
+static unsigned long _XGetPixel16(XImage *, int, int);
+static unsigned long _XGetPixel32(XImage *, int, int);
+static int _XPutPixel(XImage *, int, int, unsigned long);
+static int _XPutPixel1(XImage *, int, int, unsigned long);
+static int _XPutPixel8(XImage *, int, int, unsigned long);
+static int _XPutPixel16(XImage *, int, int, unsigned long);
+static int _XPutPixel32(XImage *, int, int, unsigned long);
+static XImage *_XSubImage(XImage *, int, int, unsigned int, unsigned int);
+static int _XAddPixel(XImage *, long);
+#endif
+
+static unsigned char Const _lomask[0x09] = { 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff };
+static unsigned char Const _himask[0x09] = { 0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00 };
+
+/* These two convenience routines return the scanline_pad and bits_per_pixel
+ associated with a specific depth of ZPixmap format image for a
+ display. */
+
+ _XGetScanlinePad(dpy, depth)
+ Display *dpy;
+ int depth;
+ {
+ register ScreenFormat *fmt = dpy->pixmap_format;
+ register int i;
+
+ for (i = dpy->nformats + 1; --i; ++fmt)
+ if (fmt->depth == depth)
+ return(fmt->scanline_pad);
+
+ return(dpy->bitmap_pad);
+ }
+
+ _XGetBitsPerPixel(dpy, depth)
+ Display *dpy;
+ int depth;
+ {
+ register ScreenFormat *fmt = dpy->pixmap_format;
+ register int i;
+
+ for (i = dpy->nformats + 1; --i; ++fmt)
+ if (fmt->depth == depth)
+ return(fmt->bits_per_pixel);
+ if (depth <= 4)
+ return 4;
+ if (depth <= 8)
+ return 8;
+ if (depth <= 16)
+ return 16;
+ return 32;
+ }
+
+
+/*
+ * This module provides rudimentary manipulation routines for image data
+ * structures. The functions provided are:
+ *
+ * XCreateImage Creates a default XImage data structure
+ * _XDestroyImage Deletes an XImage data structure
+ * _XGetPixel Reads a pixel from an image data structure
+ * _XGetPixel32 Reads a pixel from a 32-bit Z image data structure
+ * _XGetPixel16 Reads a pixel from a 16-bit Z image data structure
+ * _XGetPixel8 Reads a pixel from an 8-bit Z image data structure
+ * _XGetPixel1 Reads a pixel from an 1-bit image data structure
+ * _XPutPixel Writes a pixel into an image data structure
+ * _XPutPixel32 Writes a pixel into a 32-bit Z image data structure
+ * _XPutPixel16 Writes a pixel into a 16-bit Z image data structure
+ * _XPutPixel8 Writes a pixel into an 8-bit Z image data structure
+ * _XPutPixel1 Writes a pixel into an 1-bit image data structure
+ * _XSubImage Clones a new (sub)image from an existing one
+ * _XSetImage Writes an image data pattern into another image
+ * _XAddPixel Adds a constant value to every pixel in an image
+ *
+ * The logic contained in these routines makes several assumptions about
+ * the image data structures, and at least for current implementations
+ * these assumptions are believed to be true. They are:
+ *
+ * For all formats, bits_per_pixel is less than or equal to 32.
+ * For XY formats, bitmap_unit is always less than or equal to bitmap_pad.
+ * For XY formats, bitmap_unit is 8, 16, or 32 bits.
+ * For Z format, bits_per_pixel is 1, 4, 8, 16, 24, or 32 bits.
+ */
+static void _xynormalizeimagebits (bp, img)
+ register unsigned char *bp;
+ register XImage *img;
+{
+ register unsigned char c;
+
+ if (img->byte_order != img->bitmap_bit_order) {
+ switch (img->bitmap_unit) {
+
+ case 16:
+ c = *bp;
+ *bp = *(bp + 1);
+ *(bp + 1) = c;
+ break;
+
+ case 32:
+ c = *(bp + 3);
+ *(bp + 3) = *bp;
+ *bp = c;
+ c = *(bp + 2);
+ *(bp + 2) = *(bp + 1);
+ *(bp + 1) = c;
+ break;
+ }
+ }
+ if (img->bitmap_bit_order == MSBFirst)
+ _XReverse_Bytes (bp, img->bitmap_unit >> 3);
+}
+
+static void _znormalizeimagebits (bp, img)
+ register unsigned char *bp;
+ register XImage *img;
+{
+ register unsigned char c;
+ switch (img->bits_per_pixel) {
+
+ case 4:
+ *bp = ((*bp >> 4) & 0xF) | ((*bp << 4) & ~0xF);
+ break;
+
+ case 16:
+ c = *bp;
+ *bp = *(bp + 1);
+ *(bp + 1) = c;
+ break;
+
+ case 24:
+ c = *(bp + 2);
+ *(bp + 2) = *bp;
+ *bp = c;
+ break;
+
+ case 32:
+ c = *(bp + 3);
+ *(bp + 3) = *bp;
+ *bp = c;
+ c = *(bp + 2);
+ *(bp + 2) = *(bp + 1);
+ *(bp + 1) = c;
+ break;
+ }
+}
+
+static void _putbits (src, dstoffset, numbits, dst)
+ register char *src; /* address of source bit string */
+ int dstoffset; /* bit offset into destination; range is 0-31 */
+ register int numbits;/* number of bits to copy to destination */
+ register char *dst; /* address of destination bit string */
+{
+ register unsigned char chlo, chhi;
+ int hibits;
+ dst = dst + (dstoffset >> 3);
+ dstoffset = dstoffset & 7;
+ hibits = 8 - dstoffset;
+ chlo = *dst & _lomask[dstoffset];
+ for (;;) {
+ chhi = (*src << dstoffset) & _himask[dstoffset];
+ if (numbits <= hibits) {
+ chhi = chhi & _lomask[dstoffset + numbits];
+ *dst = (*dst & _himask[dstoffset + numbits]) | chlo | chhi;
+ break;
+ }
+ *dst = chhi | chlo;
+ dst++;
+ numbits = numbits - hibits;
+ chlo = (unsigned char) (*src & _himask[hibits]) >> hibits;
+ src++;
+ if (numbits <= dstoffset) {
+ chlo = chlo & _lomask[numbits];
+ *dst = (*dst & _himask[numbits]) | chlo;
+ break;
+ }
+ numbits = numbits - dstoffset;
+ }
+}
+
+
+/*
+ * Macros
+ *
+ * The ROUNDUP macro rounds up a quantity to the specified boundary,
+ * then truncates to bytes.
+ *
+ * The XYNORMALIZE macro determines whether XY format data requires
+ * normalization and calls a routine to do so if needed. The logic in
+ * this module is designed for LSBFirst byte and bit order, so
+ * normalization is done as required to present the data in this order.
+ *
+ * The ZNORMALIZE macro performs byte and nibble order normalization if
+ * required for Z format data.
+ *
+ * The XYINDEX macro computes the index to the starting byte (char) boundary
+ * for a bitmap_unit containing a pixel with coordinates x and y for image
+ * data in XY format.
+ *
+ * The ZINDEX macro computes the index to the starting byte (char) boundary
+ * for a pixel with coordinates x and y for image data in ZPixmap format.
+ *
+ */
+
+#define ROUNDUP(nbytes, pad) ((((nbytes) + ((pad)-1)) / (pad)) * ((pad)>>3))
+
+#define XYNORMALIZE(bp, img) \
+ if ((img->byte_order == MSBFirst) || (img->bitmap_bit_order == MSBFirst)) \
+ _xynormalizeimagebits((unsigned char *)(bp), img)
+
+#define ZNORMALIZE(bp, img) \
+ if (img->byte_order == MSBFirst) \
+ _znormalizeimagebits((unsigned char *)(bp), img)
+
+#define XYINDEX(x, y, img) \
+ ((y) * img->bytes_per_line) + \
+ (((x) + img->xoffset) / img->bitmap_unit) * (img->bitmap_unit >> 3)
+
+#define ZINDEX(x, y, img) ((y) * img->bytes_per_line) + \
+ (((x) * img->bits_per_pixel) >> 3)
+
+/*
+ * This routine initializes the image object function pointers. The
+ * intent is to provide native (i.e. fast) routines for native format images
+ * only using the generic (i.e. slow) routines when fast ones don't exist.
+ * However, with the current rather botched external interface, clients may
+ * have to mung image attributes after the image gets created, so the fast
+ * routines always have to check to make sure the optimization is still
+ * valid, and reinit the functions if not.
+ */
+void _XInitImageFuncPtrs (image)
+ register XImage *image;
+{
+ image->f.create_image = XCreateImage;
+ image->f.destroy_image = _XDestroyImage;
+ if ((image->format == ZPixmap) && (image->bits_per_pixel == 8)) {
+ image->f.get_pixel = _XGetPixel8;
+ image->f.put_pixel = _XPutPixel8;
+ } else if (((image->bits_per_pixel | image->depth) == 1) &&
+ (image->byte_order == image->bitmap_bit_order)) {
+ image->f.get_pixel = _XGetPixel1;
+ image->f.put_pixel = _XPutPixel1;
+ } else if ((image->format == ZPixmap) &&
+ (image->bits_per_pixel == 32)) {
+ image->f.get_pixel = _XGetPixel32;
+ image->f.put_pixel = _XPutPixel32;
+ } else if ((image->format == ZPixmap) &&
+ (image->bits_per_pixel == 16)) {
+ image->f.get_pixel = _XGetPixel16;
+ image->f.put_pixel = _XPutPixel16;
+ } else {
+ image->f.get_pixel = _XGetPixel;
+ image->f.put_pixel = _XPutPixel;
+ }
+ image->f.sub_image = _XSubImage;
+/* image->f.set_image = _XSetImage;*/
+ image->f.add_pixel = _XAddPixel;
+}
+
+/*
+ * CreateImage
+ *
+ * Allocates the memory necessary for an XImage data structure.
+ * Initializes the structure with "default" values and returns XImage.
+ *
+ */
+
+XImage *XCreateImage (dpy, visual, depth, format, offset, data, width, height,
+ xpad, image_bytes_per_line)
+ register Display *dpy;
+ register Visual *visual;
+ unsigned int depth;
+ int format;
+ int offset; /*How many pixels from the start of the data does the
+ picture to be transmitted start?*/
+
+ char *data;
+ unsigned int width;
+ unsigned int height;
+ int xpad;
+ int image_bytes_per_line;
+ /*How many bytes between a pixel on one line and the pixel with
+ the same X coordinate on the next line? 0 means
+ XCreateImage can calculate it.*/
+{
+ register XImage *image;
+ int bits_per_pixel = 1;
+
+ if (depth == 0 || depth > 32 ||
+ (format != XYBitmap && format != XYPixmap && format != ZPixmap) ||
+ (format == XYBitmap && depth != 1) ||
+ (xpad != 8 && xpad != 16 && xpad != 32) ||
+ offset < 0 || image_bytes_per_line < 0)
+ return (XImage *) NULL;
+ if ((image = (XImage *) Xcalloc(1, (unsigned) sizeof(XImage))) == NULL)
+ return (XImage *) NULL;
+
+ image->width = width;
+ image->height = height;
+ image->format = format;
+ image->byte_order = dpy->byte_order;
+ image->bitmap_unit = dpy->bitmap_unit;
+ image->bitmap_bit_order = dpy->bitmap_bit_order;
+ if (visual != NULL) {
+ image->red_mask = visual->red_mask;
+ image->green_mask = visual->green_mask;
+ image->blue_mask = visual->blue_mask;
+ }
+ else {
+ image->red_mask = image->green_mask = image->blue_mask = 0;
+ }
+ if (format == ZPixmap)
+ {
+ bits_per_pixel = _XGetBitsPerPixel(dpy, (int) depth);
+ }
+
+ image->xoffset = offset;
+ image->bitmap_pad = xpad;
+ image->depth = depth;
+ image->data = data;
+ /*
+ * compute per line accelerator.
+ */
+ if (image_bytes_per_line == 0)
+ {
+ if (format == ZPixmap)
+ image->bytes_per_line =
+ ROUNDUP((bits_per_pixel * width), image->bitmap_pad);
+ else
+ image->bytes_per_line =
+ ROUNDUP((width + offset), image->bitmap_pad);
+ }
+ else image->bytes_per_line = image_bytes_per_line;
+
+ image->bits_per_pixel = bits_per_pixel;
+ image->obdata = NULL;
+ _XInitImageFuncPtrs (image);
+
+ return image;
+}
+
+Status XInitImage (image)
+ XImage *image;
+{
+ if (image->depth == 0 || image->depth > 32 ||
+ (image->format != XYBitmap &&
+ image->format != XYPixmap &&
+ image->format != ZPixmap) ||
+ (image->format == XYBitmap && image->depth != 1) ||
+ (image->bitmap_pad != 8 &&
+ image->bitmap_pad != 16 &&
+ image->bitmap_pad != 32) ||
+ image->xoffset < 0 || image->bytes_per_line < 0)
+ return 0;
+
+ /*
+ * compute per line accelerator.
+ */
+ if (image->bytes_per_line == 0)
+ {
+ if (image->format == ZPixmap)
+ image->bytes_per_line =
+ ROUNDUP((image->bits_per_pixel * image->width),
+ image->bitmap_pad);
+ else
+ image->bytes_per_line =
+ ROUNDUP((image->width + image->xoffset), image->bitmap_pad);
+ }
+
+ _XInitImageFuncPtrs (image);
+
+ return 1;
+}
+
+/*
+ * _DestroyImage
+ *
+ * Deallocates the memory associated with the ximage data structure.
+ * this version handles the case of the image data being malloc'd
+ * entirely by the library.
+ */
+
+static int _XDestroyImage (ximage)
+ XImage *ximage;
+
+{
+ if (ximage->data != NULL) Xfree((char *)ximage->data);
+ if (ximage->obdata != NULL) Xfree((char *)ximage->obdata);
+ Xfree((char *)ximage);
+ return 1;
+}
+
+
+/*
+ * GetPixel
+ *
+ * Returns the specified pixel. The X and Y coordinates are relative to
+ * the origin (upper left [0,0]) of the image. The pixel value is returned
+ * in normalized format, i.e. the LSB of the long is the LSB of the pixel.
+ * The algorithm used is:
+ *
+ * copy the source bitmap_unit or Zpixel into temp
+ * normalize temp if needed
+ * extract the pixel bits into return value
+ *
+ */
+
+static unsigned long Const low_bits_table[] = {
+ 0x00000000, 0x00000001, 0x00000003, 0x00000007,
+ 0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f,
+ 0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff,
+ 0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff,
+ 0x0000ffff, 0x0001ffff, 0x0003ffff, 0x0007ffff,
+ 0x000fffff, 0x001fffff, 0x003fffff, 0x007fffff,
+ 0x00ffffff, 0x01ffffff, 0x03ffffff, 0x07ffffff,
+ 0x0fffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff,
+ 0xffffffff
+};
+
+static unsigned long _XGetPixel (ximage, x, y)
+ register XImage *ximage;
+ int x;
+ int y;
+
+{
+ unsigned long pixel, px;
+ register char *src;
+ register char *dst;
+ register int i, j;
+ int bits, nbytes;
+ long plane;
+
+ if ((ximage->bits_per_pixel | ximage->depth) == 1) {
+ src = &ximage->data[XYINDEX(x, y, ximage)];
+ dst = (char *)&pixel;
+ pixel = 0;
+ for (i = ximage->bitmap_unit >> 3; --i >= 0; ) *dst++ = *src++;
+ XYNORMALIZE(&pixel, ximage);
+ bits = (x + ximage->xoffset) % ximage->bitmap_unit;
+ pixel = ((((char *)&pixel)[bits>>3])>>(bits&7)) & 1;
+ } else if (ximage->format == XYPixmap) {
+ pixel = 0;
+ plane = 0;
+ nbytes = ximage->bitmap_unit >> 3;
+ for (i = ximage->depth; --i >= 0; ) {
+ src = &ximage->data[XYINDEX(x, y, ximage)+ plane];
+ dst = (char *)&px;
+ px = 0;
+ for (j = nbytes; --j >= 0; ) *dst++ = *src++;
+ XYNORMALIZE(&px, ximage);
+ bits = (x + ximage->xoffset) % ximage->bitmap_unit;
+ pixel = (pixel << 1) |
+ (((((char *)&px)[bits>>3])>>(bits&7)) & 1);
+ plane = plane + (ximage->bytes_per_line * ximage->height);
+ }
+ } else if (ximage->format == ZPixmap) {
+ src = &ximage->data[ZINDEX(x, y, ximage)];
+ dst = (char *)&px;
+ px = 0;
+ for (i = (ximage->bits_per_pixel + 7) >> 3; --i >= 0; )
+ *dst++ = *src++;
+ ZNORMALIZE(&px, ximage);
+ pixel = 0;
+ for (i=sizeof(unsigned long); --i >= 0; )
+ pixel = (pixel << 8) | ((unsigned char *)&px)[i];
+ if (ximage->bits_per_pixel == 4) {
+ if (x & 1)
+ pixel >>= 4;
+ else
+ pixel &= 0xf;
+ }
+ } else {
+ return 0; /* bad image */
+ }
+ if (ximage->bits_per_pixel == ximage->depth)
+ return pixel;
+ else
+ return (pixel & low_bits_table[ximage->depth]);
+}
+
+#ifndef WORD64
+static unsigned long byteorderpixel = MSBFirst << 24;
+#endif
+
+static unsigned long _XGetPixel32 (ximage, x, y)
+ register XImage *ximage;
+ int x;
+ int y;
+{
+ register unsigned char *addr;
+ unsigned long pixel;
+
+ if ((ximage->format == ZPixmap) && (ximage->bits_per_pixel == 32)) {
+ addr = &((unsigned char *)ximage->data)
+ [y * ximage->bytes_per_line + (x << 2)];
+#ifndef WORD64
+ if (*((char *)&byteorderpixel) == ximage->byte_order)
+ pixel = *((CARD32 *)addr);
+ else
+#endif
+ if (ximage->byte_order == MSBFirst)
+ pixel = ((unsigned long)addr[0] << 24 |
+ (unsigned long)addr[1] << 16 |
+ (unsigned long)addr[2] << 8 |
+ addr[3]);
+ else
+ pixel = ((unsigned long)addr[3] << 24 |
+ (unsigned long)addr[2] << 16 |
+ (unsigned long)addr[1] << 8 |
+ addr[0]);
+ if (ximage->depth != 32)
+ pixel &= low_bits_table[ximage->depth];
+ return pixel;
+ } else {
+ _XInitImageFuncPtrs(ximage);
+ return XGetPixel(ximage, x, y);
+ }
+}
+
+static unsigned long _XGetPixel16 (ximage, x, y)
+ register XImage *ximage;
+ int x;
+ int y;
+{
+ register unsigned char *addr;
+ unsigned long pixel;
+
+ if ((ximage->format == ZPixmap) && (ximage->bits_per_pixel == 16)) {
+ addr = &((unsigned char *)ximage->data)
+ [y * ximage->bytes_per_line + (x << 1)];
+ if (ximage->byte_order == MSBFirst)
+ pixel = addr[0] << 8 | addr[1];
+ else
+ pixel = addr[1] << 8 | addr[0];
+ if (ximage->depth != 16)
+ pixel &= low_bits_table[ximage->depth];
+ return pixel;
+ } else {
+ _XInitImageFuncPtrs(ximage);
+ return XGetPixel(ximage, x, y);
+ }
+}
+
+static unsigned long _XGetPixel8 (ximage, x, y)
+ register XImage *ximage;
+ int x;
+ int y;
+{
+ unsigned char pixel;
+
+ if ((ximage->format == ZPixmap) && (ximage->bits_per_pixel == 8)) {
+ pixel = ((unsigned char *)ximage->data)
+ [y * ximage->bytes_per_line + x];
+ if (ximage->depth != 8)
+ pixel &= low_bits_table[ximage->depth];
+ return pixel;
+ } else {
+ _XInitImageFuncPtrs(ximage);
+ return XGetPixel(ximage, x, y);
+ }
+}
+
+static unsigned long _XGetPixel1 (ximage, x, y)
+ register XImage *ximage;
+ int x;
+ int y;
+{
+ unsigned char bit;
+ int xoff, yoff;
+
+ if (((ximage->bits_per_pixel | ximage->depth) == 1) &&
+ (ximage->byte_order == ximage->bitmap_bit_order)) {
+ xoff = x + ximage->xoffset;
+ yoff = y * ximage->bytes_per_line + (xoff >> 3);
+ xoff &= 7;
+ if (ximage->bitmap_bit_order == MSBFirst)
+ bit = 0x80 >> xoff;
+ else
+ bit = 1 << xoff;
+ return (ximage->data[yoff] & bit) ? 1 : 0;
+ } else {
+ _XInitImageFuncPtrs(ximage);
+ return XGetPixel(ximage, x, y);
+ }
+}
+
+/*
+ * PutPixel
+ *
+ * Overwrites the specified pixel. The X and Y coordinates are relative to
+ * the origin (upper left [0,0]) of the image. The input pixel value must be
+ * in normalized format, i.e. the LSB of the long is the LSB of the pixel.
+ * The algorithm used is:
+ *
+ * copy the destination bitmap_unit or Zpixel to temp
+ * normalize temp if needed
+ * copy the pixel bits into the temp
+ * renormalize temp if needed
+ * copy the temp back into the destination image data
+ *
+ */
+
+static int _XPutPixel (ximage, x, y, pixel)
+ register XImage *ximage;
+ int x;
+ int y;
+ unsigned long pixel;
+
+{
+ unsigned long px, npixel;
+ register char *src;
+ register char *dst;
+ register int i;
+ int j, nbytes;
+ long plane;
+
+ if (ximage->depth == 4)
+ pixel &= 0xf;
+ npixel = pixel;
+ for (i=0, px=pixel; i<sizeof(unsigned long); i++, px>>=8)
+ ((unsigned char *)&pixel)[i] = px;
+ if ((ximage->bits_per_pixel | ximage->depth) == 1) {
+ src = &ximage->data[XYINDEX(x, y, ximage)];
+ dst = (char *)&px;
+ px = 0;
+ nbytes = ximage->bitmap_unit >> 3;
+ for (i = nbytes; --i >= 0; ) *dst++ = *src++;
+ XYNORMALIZE(&px, ximage);
+ i = ((x + ximage->xoffset) % ximage->bitmap_unit);
+ _putbits ((char *)&pixel, i, 1, (char *)&px);
+ XYNORMALIZE(&px, ximage);
+ src = (char *) &px;
+ dst = &ximage->data[XYINDEX(x, y, ximage)];
+ for (i = nbytes; --i >= 0; ) *dst++ = *src++;
+ } else if (ximage->format == XYPixmap) {
+ plane = (ximage->bytes_per_line * ximage->height) *
+ (ximage->depth - 1); /* do least signif plane 1st */
+ nbytes = ximage->bitmap_unit >> 3;
+ for (j = ximage->depth; --j >= 0; ) {
+ src = &ximage->data[XYINDEX(x, y, ximage) + plane];
+ dst = (char *) &px;
+ px = 0;
+ for (i = nbytes; --i >= 0; ) *dst++ = *src++;
+ XYNORMALIZE(&px, ximage);
+ i = ((x + ximage->xoffset) % ximage->bitmap_unit);
+ _putbits ((char *)&pixel, i, 1, (char *)&px);
+ XYNORMALIZE(&px, ximage);
+ src = (char *)&px;
+ dst = &ximage->data[XYINDEX(x, y, ximage) + plane];
+ for (i = nbytes; --i >= 0; ) *dst++ = *src++;
+ npixel = npixel >> 1;
+ for (i=0, px=npixel; i<sizeof(unsigned long); i++, px>>=8)
+ ((unsigned char *)&pixel)[i] = px;
+ plane = plane - (ximage->bytes_per_line * ximage->height);
+ }
+ } else if (ximage->format == ZPixmap) {
+ src = &ximage->data[ZINDEX(x, y, ximage)];
+ dst = (char *)&px;
+ px = 0;
+ nbytes = (ximage->bits_per_pixel + 7) >> 3;
+ for (i = nbytes; --i >= 0; ) *dst++ = *src++;
+ ZNORMALIZE(&px, ximage);
+ _putbits ((char *)&pixel,
+ (x * ximage->bits_per_pixel) & 7,
+ ximage->bits_per_pixel, (char *)&px);
+ ZNORMALIZE(&px, ximage);
+ src = (char *)&px;
+ dst = &ximage->data[ZINDEX(x, y, ximage)];
+ for (i = nbytes; --i >= 0; ) *dst++ = *src++;
+ } else {
+ return 0; /* bad image */
+ }
+ return 1;
+}
+
+static int _XPutPixel32 (ximage, x, y, pixel)
+ register XImage *ximage;
+ int x;
+ int y;
+ unsigned long pixel;
+{
+ unsigned char *addr;
+
+ if ((ximage->format == ZPixmap) && (ximage->bits_per_pixel == 32)) {
+ addr = &((unsigned char *)ximage->data)
+ [y * ximage->bytes_per_line + (x << 2)];
+#ifndef WORD64
+ if (*((char *)&byteorderpixel) == ximage->byte_order)
+ *((CARD32 *)addr) = pixel;
+ else
+#endif
+ if (ximage->byte_order == MSBFirst) {
+ addr[0] = pixel >> 24;
+ addr[1] = pixel >> 16;
+ addr[2] = pixel >> 8;
+ addr[3] = pixel;
+ } else {
+ addr[3] = pixel >> 24;
+ addr[2] = pixel >> 16;
+ addr[1] = pixel >> 8;
+ addr[0] = pixel;
+ }
+ return 1;
+ } else {
+ _XInitImageFuncPtrs(ximage);
+ return XPutPixel(ximage, x, y, pixel);
+ }
+}
+
+static int _XPutPixel16 (ximage, x, y, pixel)
+ register XImage *ximage;
+ int x;
+ int y;
+ unsigned long pixel;
+{
+ unsigned char *addr;
+
+ if ((ximage->format == ZPixmap) && (ximage->bits_per_pixel == 16)) {
+ addr = &((unsigned char *)ximage->data)
+ [y * ximage->bytes_per_line + (x << 1)];
+ if (ximage->byte_order == MSBFirst) {
+ addr[0] = pixel >> 8;
+ addr[1] = pixel;
+ } else {
+ addr[1] = pixel >> 8;
+ addr[0] = pixel;
+ }
+ return 1;
+ } else {
+ _XInitImageFuncPtrs(ximage);
+ return XPutPixel(ximage, x, y, pixel);
+ }
+}
+
+static int _XPutPixel8 (ximage, x, y, pixel)
+ register XImage *ximage;
+ int x;
+ int y;
+ unsigned long pixel;
+{
+ if ((ximage->format == ZPixmap) && (ximage->bits_per_pixel == 8)) {
+ ximage->data[y * ximage->bytes_per_line + x] = pixel;
+ return 1;
+ } else {
+ _XInitImageFuncPtrs(ximage);
+ return XPutPixel(ximage, x, y, pixel);
+ }
+}
+
+static int _XPutPixel1 (ximage, x, y, pixel)
+ register XImage *ximage;
+ int x;
+ int y;
+ unsigned long pixel;
+{
+ unsigned char bit;
+ int xoff, yoff;
+
+ if (((ximage->bits_per_pixel | ximage->depth) == 1) &&
+ (ximage->byte_order == ximage->bitmap_bit_order)) {
+ xoff = x + ximage->xoffset;
+ yoff = y * ximage->bytes_per_line + (xoff >> 3);
+ xoff &= 7;
+ if (ximage->bitmap_bit_order == MSBFirst)
+ bit = 0x80 >> xoff;
+ else
+ bit = 1 << xoff;
+ if (pixel & 1)
+ ximage->data[yoff] |= bit;
+ else
+ ximage->data[yoff] &= ~bit;
+ return 1;
+ } else {
+ _XInitImageFuncPtrs(ximage);
+ return XPutPixel(ximage, x, y, pixel);
+ }
+}
+
+/*
+ * SubImage
+ *
+ * Creates a new image that is a subsection of an existing one.
+ * Allocates the memory necessary for the new XImage data structure.
+ * Pointer to new image is returned. The algorithm used is repetitive
+ * calls to get and put pixel.
+ *
+ */
+
+static XImage *_XSubImage (ximage, x, y, width, height)
+ XImage *ximage;
+ register int x; /* starting x coordinate in existing image */
+ register int y; /* starting y coordinate in existing image */
+ unsigned int width; /* width in pixels of new subimage */
+ unsigned int height;/* height in pixels of new subimage */
+
+{
+ register XImage *subimage;
+ int dsize;
+ register int row, col;
+ register unsigned long pixel;
+ char *data;
+
+ if ((subimage = (XImage *) Xcalloc (1, sizeof (XImage))) == NULL)
+ return (XImage *) NULL;
+ subimage->width = width;
+ subimage->height = height;
+ subimage->xoffset = 0;
+ subimage->format = ximage->format;
+ subimage->byte_order = ximage->byte_order;
+ subimage->bitmap_unit = ximage->bitmap_unit;
+ subimage->bitmap_bit_order = ximage->bitmap_bit_order;
+ subimage->bitmap_pad = ximage->bitmap_pad;
+ subimage->bits_per_pixel = ximage->bits_per_pixel;
+ subimage->depth = ximage->depth;
+ /*
+ * compute per line accelerator.
+ */
+ if (subimage->format == ZPixmap)
+ subimage->bytes_per_line =
+ ROUNDUP(subimage->bits_per_pixel * width,
+ subimage->bitmap_pad);
+ else
+ subimage->bytes_per_line =
+ ROUNDUP(width, subimage->bitmap_pad);
+ subimage->obdata = NULL;
+ _XInitImageFuncPtrs (subimage);
+ dsize = subimage->bytes_per_line * height;
+ if (subimage->format == XYPixmap) dsize = dsize * subimage->depth;
+ if (((data = Xcalloc (1, (unsigned) dsize)) == NULL) && (dsize > 0)) {
+ Xfree((char *) subimage);
+ return (XImage *) NULL;
+ }
+ subimage->data = data;
+
+ /*
+ * Test for cases where the new subimage is larger than the region
+ * that we are copying from the existing data. In those cases,
+ * copy the area of the existing image, and allow the "uncovered"
+ * area of new subimage to remain with zero filled pixels.
+ */
+ if (height > ximage->height - y ) height = ximage->height - y;
+ if (width > ximage->width - x ) width = ximage->width - x;
+
+ for (row = y; row < (y + height); row++) {
+ for (col = x; col < (x + width); col++) {
+ pixel = XGetPixel(ximage, col, row);
+ XPutPixel(subimage, (col - x), (row - y), pixel);
+ }
+ }
+ return subimage;
+}
+
+
+/*
+ * SetImage
+ *
+ * Overwrites a section of one image with all of the data from another.
+ * If the two images are not of the same format (i.e. XYPixmap and ZPixmap),
+ * the image data is converted to the destination format. The following
+ * restrictions apply:
+ *
+ * 1. The depths of the source and destination images must be equal.
+ *
+ * 2. If the height of the source image is too large to fit between
+ * the specified y starting point and the bottom of the image,
+ * then scanlines are truncated on the bottom.
+ *
+ * 3. If the width of the source image is too large to fit between
+ * the specified x starting point and the end of the scanline,
+ * then pixels are truncated on the right.
+ *
+ * The images need not have the same bitmap_bit_order, byte_order,
+ * bitmap_unit, bits_per_pixel, bitmap_pad, or xoffset.
+ *
+ */
+
+int _XSetImage (srcimg, dstimg, x, y)
+ XImage *srcimg;
+ register XImage *dstimg;
+ register int x;
+ register int y;
+
+{
+ register unsigned long pixel;
+ register int row, col;
+ int width, height, startrow, startcol;
+ if (x < 0) {
+ startcol = -x;
+ x = 0;
+ } else
+ startcol = 0;
+ if (y < 0) {
+ startrow = -y;
+ y = 0;
+ } else
+ startrow = 0;
+ width = dstimg->width - x;
+ if (srcimg->width < width)
+ width = srcimg->width;
+ height = dstimg->height - y;
+ if (srcimg->height < height)
+ height = srcimg->height;
+
+ /* this is slow, will do better later */
+ for (row = startrow; row < height; row++) {
+ for (col = startcol; col < width; col++) {
+ pixel = XGetPixel(srcimg, col, row);
+ XPutPixel(dstimg, x + col, y + row, pixel);
+ }
+ }
+ return 1;
+}
+
+/*
+ * AddPixel
+ *
+ * Adds a constant value to every pixel in a pixmap.
+ *
+ */
+
+static _XAddPixel (ximage, value)
+ register XImage *ximage;
+ register long value;
+{
+ register int x;
+ register int y;
+
+ if (!value)
+ return 0;
+ if ((ximage->bits_per_pixel | ximage->depth) == 1) {
+ /* The only value that we can add here to an XYBitmap
+ * is one. Since 1 + value = ~value for one bit wide
+ * data, we do this quickly by taking the ones complement
+ * of the entire bitmap data (offset and pad included!).
+ * Note that we don't need to be concerned with bit or
+ * byte order at all.
+ */
+ register unsigned char *dp = (unsigned char *) ximage->data;
+ x = ximage->bytes_per_line * ximage->height;
+ while (--x >= 0) {
+ *dp = ~*dp;
+ dp++;
+ }
+ } else if ((ximage->format == ZPixmap) &&
+ (ximage->bits_per_pixel == 8)) {
+ register unsigned char *dp = (unsigned char *) ximage->data;
+ x = ximage->bytes_per_line * ximage->height;
+ while (--x >= 0)
+ *dp++ += value;
+#ifndef WORD64
+ } else if ((ximage->format == ZPixmap) &&
+ (ximage->bits_per_pixel == 16) &&
+ (*((char *)&byteorderpixel) == ximage->byte_order)) {
+ register unsigned short *dp = (unsigned short *) ximage->data;
+ x = (ximage->bytes_per_line >> 1) * ximage->height;
+ while (--x >= 0)
+ *dp++ += value;
+ } else if ((ximage->format == ZPixmap) &&
+ (ximage->bits_per_pixel == 32) &&
+ (*((char *)&byteorderpixel) == ximage->byte_order)) {
+ register CARD32 *dp = (CARD32 *) ximage->data;
+ x = (ximage->bytes_per_line >> 2) * ximage->height;
+ while (--x >= 0)
+ *dp++ += value;
+#endif
+ } else {
+ for (y = ximage->height; --y >= 0; ) {
+ for (x = ximage->width; --x >= 0; ) {
+ register unsigned long pixel = XGetPixel(ximage, x, y);
+ pixel = pixel + value;
+ XPutPixel(ximage, x, y, pixel);
+ }
+ }
+ }
+ return 0;
+}
+
diff --git a/src/InitExt.c b/src/InitExt.c
new file mode 100644
index 00000000..c24d4490
--- /dev/null
+++ b/src/InitExt.c
@@ -0,0 +1,473 @@
+/* $Xorg: InitExt.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#include <X11/Xlibint.h>
+#include <X11/Xos.h>
+#include <stdio.h>
+
+extern Bool _XUnknownWireEvent();
+extern Status _XUnknownNativeEvent();
+extern Bool _XDefaultWireError();
+
+/*
+ * This routine is used to link a extension in so it will be called
+ * at appropriate times.
+ */
+
+#if NeedFunctionPrototypes
+XExtCodes *XInitExtension (
+ Display *dpy,
+ _Xconst char *name)
+#else
+XExtCodes *XInitExtension (dpy, name)
+ Display *dpy;
+ char *name;
+#endif
+{
+ XExtCodes codes; /* temp. place for extension information. */
+ register _XExtension *ext;/* need a place to build it all */
+ if (!XQueryExtension(dpy, name,
+ &codes.major_opcode, &codes.first_event,
+ &codes.first_error)) return (NULL);
+
+ LockDisplay (dpy);
+ if (! (ext = (_XExtension *) Xcalloc (1, sizeof (_XExtension))) ||
+ ! (ext->name = Xmalloc((unsigned) strlen(name) + 1))) {
+ if (ext) Xfree((char *) ext);
+ UnlockDisplay(dpy);
+ return (XExtCodes *) NULL;
+ }
+ codes.extension = dpy->ext_number++;
+ ext->codes = codes;
+ (void) strcpy(ext->name, name);
+
+ /* chain it onto the display list */
+ ext->next = dpy->ext_procs;
+ dpy->ext_procs = ext;
+ UnlockDisplay (dpy);
+
+ return (&ext->codes); /* tell him which extension */
+}
+
+XExtCodes *XAddExtension (dpy)
+ Display *dpy;
+{
+ register _XExtension *ext;
+
+ LockDisplay (dpy);
+ if (! (ext = (_XExtension *) Xcalloc (1, sizeof (_XExtension)))) {
+ UnlockDisplay(dpy);
+ return (XExtCodes *) NULL;
+ }
+ ext->codes.extension = dpy->ext_number++;
+
+ /* chain it onto the display list */
+ ext->next = dpy->ext_procs;
+ dpy->ext_procs = ext;
+ UnlockDisplay (dpy);
+
+ return (&ext->codes); /* tell him which extension */
+}
+
+static _XExtension *XLookupExtension (dpy, extension)
+ register Display *dpy; /* display */
+ register int extension; /* extension number */
+{
+ register _XExtension *ext;
+ for (ext = dpy->ext_procs; ext; ext = ext->next)
+ if (ext->codes.extension == extension) return (ext);
+ return (NULL);
+}
+
+XExtData **XEHeadOfExtensionList(object)
+ XEDataObject object;
+{
+ return *(XExtData ***)&object;
+}
+
+XAddToExtensionList(structure, ext_data)
+ XExtData **structure;
+ XExtData *ext_data;
+{
+ ext_data->next = *structure;
+ *structure = ext_data;
+ return 1;
+}
+
+XExtData *XFindOnExtensionList(structure, number)
+ XExtData **structure;
+ int number;
+{
+ XExtData *ext;
+
+ ext = *structure;
+ while (ext && (ext->number != number))
+ ext = ext->next;
+ return ext;
+}
+
+typedef int (*CreateGCType) (
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ GC /* gc */,
+ XExtCodes* /* codes */
+#endif
+);
+
+/*
+ * Routines to hang procs on the extension structure.
+ */
+CreateGCType XESetCreateGC(dpy, extension, proc)
+ Display *dpy; /* display */
+ int extension; /* extension number */
+ CreateGCType proc; /* routine to call when GC created */
+{
+ register _XExtension *e; /* for lookup of extension */
+ register int (*oldproc)();
+ if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
+ LockDisplay(dpy);
+ oldproc = e->create_GC;
+ e->create_GC = proc;
+ UnlockDisplay(dpy);
+ return (CreateGCType)oldproc;
+}
+
+typedef int (*CopyGCType)(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ GC /* gc */,
+ XExtCodes* /* codes */
+#endif
+);
+
+CopyGCType XESetCopyGC(dpy, extension, proc)
+ Display *dpy; /* display */
+ int extension; /* extension number */
+ CopyGCType proc; /* routine to call when GC copied */
+{
+ register _XExtension *e; /* for lookup of extension */
+ register int (*oldproc)();
+ if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
+ LockDisplay(dpy);
+ oldproc = e->copy_GC;
+ e->copy_GC = proc;
+ UnlockDisplay(dpy);
+ return (CopyGCType)oldproc;
+}
+
+typedef int (*FlushGCType) (
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ GC /* gc */,
+ XExtCodes* /* codes */
+#endif
+);
+
+FlushGCType XESetFlushGC(dpy, extension, proc)
+ Display *dpy; /* display */
+ int extension; /* extension number */
+ FlushGCType proc; /* routine to call when GC copied */
+{
+ register _XExtension *e; /* for lookup of extension */
+ register int (*oldproc)();
+ if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
+ LockDisplay(dpy);
+ oldproc = e->flush_GC;
+ e->flush_GC = proc;
+ UnlockDisplay(dpy);
+ return (FlushGCType)oldproc;
+}
+
+typedef int (*FreeGCType) (
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ GC /* gc */,
+ XExtCodes* /* codes */
+#endif
+);
+
+FreeGCType XESetFreeGC(dpy, extension, proc)
+ Display *dpy; /* display */
+ int extension; /* extension number */
+ FreeGCType proc; /* routine to call when GC freed */
+{
+ register _XExtension *e; /* for lookup of extension */
+ register int (*oldproc)();
+ if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
+ LockDisplay(dpy);
+ oldproc = e->free_GC;
+ e->free_GC = proc;
+ UnlockDisplay(dpy);
+ return (FreeGCType)oldproc;
+}
+
+typedef int (*CreateFontType) (
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XFontStruct* /* fs */,
+ XExtCodes* /* codes */
+#endif
+);
+
+CreateFontType XESetCreateFont(dpy, extension, proc)
+ Display *dpy; /* display */
+ int extension; /* extension number */
+ CreateFontType proc; /* routine to call when font created */
+{
+ register _XExtension *e; /* for lookup of extension */
+ register int (*oldproc)();
+ if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
+ LockDisplay(dpy);
+ oldproc = e->create_Font;
+ e->create_Font = proc;
+ UnlockDisplay(dpy);
+ return (CreateFontType)oldproc;
+}
+
+typedef int (*FreeFontType) (
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XFontStruct* /* fs */,
+ XExtCodes* /* codes */
+#endif
+);
+
+FreeFontType XESetFreeFont(dpy, extension, proc)
+ Display *dpy; /* display */
+ int extension; /* extension number */
+ FreeFontType proc; /* routine to call when font freed */
+{
+ register _XExtension *e; /* for lookup of extension */
+ register int (*oldproc)();
+ if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
+ LockDisplay(dpy);
+ oldproc = e->free_Font;
+ e->free_Font = proc;
+ UnlockDisplay(dpy);
+ return (FreeFontType)oldproc;
+}
+
+typedef int (*CloseDisplayType) (
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XExtCodes* /* codes */
+#endif
+);
+
+CloseDisplayType XESetCloseDisplay(dpy, extension, proc)
+ Display *dpy; /* display */
+ int extension; /* extension number */
+ CloseDisplayType proc; /* routine to call when display closed */
+{
+ register _XExtension *e; /* for lookup of extension */
+ register int (*oldproc)();
+ if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
+ LockDisplay(dpy);
+ oldproc = e->close_display;
+ e->close_display = proc;
+ UnlockDisplay(dpy);
+ return (CloseDisplayType)oldproc;
+}
+
+typedef Bool (*WireToEventType) (
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XEvent* /* re */,
+ xEvent* /* event */
+#endif
+);
+
+WireToEventType XESetWireToEvent(dpy, event_number, proc)
+ Display *dpy; /* display */
+ WireToEventType proc; /* routine to call when converting event */
+ int event_number; /* event routine to replace */
+{
+ register Bool (*oldproc)();
+ if (proc == NULL) proc = (WireToEventType)_XUnknownWireEvent;
+ LockDisplay (dpy);
+ oldproc = dpy->event_vec[event_number];
+ dpy->event_vec[event_number] = proc;
+ UnlockDisplay (dpy);
+ return (WireToEventType)oldproc;
+}
+
+typedef Status (*EventToWireType) (
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XEvent* /* re */,
+ xEvent* /* event */
+#endif
+);
+
+EventToWireType XESetEventToWire(dpy, event_number, proc)
+ Display *dpy; /* display */
+ EventToWireType proc; /* routine to call when converting event */
+ int event_number; /* event routine to replace */
+{
+ register Status (*oldproc)();
+ if (proc == NULL) proc = (EventToWireType) _XUnknownNativeEvent;
+ LockDisplay (dpy);
+ oldproc = dpy->wire_vec[event_number];
+ dpy->wire_vec[event_number] = proc;
+ UnlockDisplay(dpy);
+ return (EventToWireType)oldproc;
+}
+
+typedef Bool (*WireToErrorType) (
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XErrorEvent* /* he */,
+ xError* /* we */
+#endif
+);
+
+WireToErrorType XESetWireToError(dpy, error_number, proc)
+ Display *dpy; /* display */
+ WireToErrorType proc; /* routine to call when converting error */
+ int error_number; /* error routine to replace */
+{
+ register Bool (*oldproc)();
+ if (proc == NULL) proc = (WireToErrorType)_XDefaultWireError;
+ LockDisplay (dpy);
+ if (!dpy->error_vec) {
+ int i;
+ dpy->error_vec = (Bool (**)())Xmalloc(256 * sizeof(oldproc));
+ for (i = 1; i < 256; i++)
+ dpy->error_vec[i] = _XDefaultWireError;
+ }
+ if (dpy->error_vec) {
+ oldproc = dpy->error_vec[error_number];
+ dpy->error_vec[error_number] = proc;
+ }
+ UnlockDisplay (dpy);
+ return (WireToErrorType)oldproc;
+}
+
+typedef int (*ErrorType) (
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ xError* /* err */,
+ XExtCodes* /* codes */,
+ int* /* ret_code */
+#endif
+);
+
+ErrorType XESetError(dpy, extension, proc)
+ Display *dpy; /* display */
+ int extension; /* extension number */
+ ErrorType proc; /* routine to call when X error happens */
+{
+ register _XExtension *e; /* for lookup of extension */
+ register int (*oldproc)();
+ if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
+ LockDisplay(dpy);
+ oldproc = e->error;
+ e->error = proc;
+ UnlockDisplay(dpy);
+ return (ErrorType)oldproc;
+}
+
+typedef char* (*ErrorStringType) (
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* code */,
+ XExtCodes* /* codes */,
+ char* /* buffer */,
+ int /* nbytes */
+#endif
+);
+
+ErrorStringType XESetErrorString(dpy, extension, proc)
+ Display *dpy; /* display */
+ int extension; /* extension number */
+ ErrorStringType proc; /* routine to call when I/O error happens */
+{
+ register _XExtension *e; /* for lookup of extension */
+ register char *(*oldproc)();
+ if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
+ LockDisplay(dpy);
+ oldproc = e->error_string;
+ e->error_string = proc;
+ UnlockDisplay(dpy);
+ return (ErrorStringType)oldproc;
+}
+
+typedef void (*PrintErrorType)(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XErrorEvent* /* ev */,
+ void* /* fp */
+#endif
+);
+
+PrintErrorType XESetPrintErrorValues(dpy, extension, proc)
+ Display *dpy; /* display */
+ int extension; /* extension number */
+ PrintErrorType proc; /* routine to call to print */
+{
+ register _XExtension *e; /* for lookup of extension */
+ register void (*oldproc)();
+ if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
+ LockDisplay(dpy);
+ oldproc = e->error_values;
+ e->error_values = proc;
+ UnlockDisplay(dpy);
+ return (PrintErrorType)oldproc;
+}
+
+typedef void (*BeforeFlushType)(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XExtCodes* /* codes */,
+ char* /* data */,
+ long /* len */
+#endif
+);
+
+BeforeFlushType XESetBeforeFlush(dpy, extension, proc)
+ Display *dpy; /* display */
+ int extension; /* extension number */
+ BeforeFlushType proc; /* routine to call on flush */
+{
+ register _XExtension *e; /* for lookup of extension */
+ register void (*oldproc)();
+ register _XExtension *ext;
+ if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
+ LockDisplay(dpy);
+ oldproc = e->before_flush;
+ e->before_flush = proc;
+ for (ext = dpy->flushes; ext && ext != e; ext = ext->next)
+ ;
+ if (!ext) {
+ e->next_flush = dpy->flushes;
+ dpy->flushes = e;
+ }
+ UnlockDisplay(dpy);
+ return (BeforeFlushType)oldproc;
+}
diff --git a/src/InsCmap.c b/src/InsCmap.c
new file mode 100644
index 00000000..1e10d953
--- /dev/null
+++ b/src/InsCmap.c
@@ -0,0 +1,41 @@
+/* $Xorg: InsCmap.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XInstallColormap(dpy, cmap)
+register Display *dpy;
+Colormap cmap;
+{
+ register xResourceReq *req;
+ LockDisplay(dpy);
+ GetResReq(InstallColormap, cmap, req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/IntAtom.c b/src/IntAtom.c
new file mode 100644
index 00000000..467286b0
--- /dev/null
+++ b/src/IntAtom.c
@@ -0,0 +1,319 @@
+/* $Xorg: IntAtom.c,v 1.5 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+/* XXX this table def is duplicated in GetAtomNm.c, keep them consistent! */
+
+#define TABLESIZE 64
+
+typedef struct _Entry {
+ unsigned long sig;
+ Atom atom;
+} EntryRec, *Entry;
+
+#define RESERVED ((Entry) 1)
+
+#define EntryName(e) ((char *)(e+1))
+
+typedef struct _XDisplayAtoms {
+ Entry table[TABLESIZE];
+} AtomTable;
+
+#define HASH(sig) ((sig) & (TABLESIZE-1))
+#define REHASHVAL(sig) ((((sig) % (TABLESIZE-3)) + 2) | 1)
+#define REHASH(idx,rehash) ((idx + rehash) & (TABLESIZE-1))
+
+void
+_XFreeAtomTable(dpy)
+ Display *dpy;
+{
+ register Entry *table;
+ register int i;
+ register Entry e;
+
+ if (dpy->atoms) {
+ table = dpy->atoms->table;
+ for (i = TABLESIZE; --i >= 0; ) {
+ if ((e = *table++) && (e != RESERVED))
+ Xfree((char *)e);
+ }
+ Xfree((char *)dpy->atoms);
+ }
+}
+
+static
+Atom _XInternAtom(dpy, name, onlyIfExists, psig, pidx, pn)
+ Display *dpy;
+ char *name;
+ Bool onlyIfExists;
+ unsigned long *psig;
+ int *pidx;
+ int *pn;
+{
+ register AtomTable *atoms;
+ register char *s1, c, *s2;
+ register unsigned long sig;
+ register int idx, i;
+ Entry e;
+ int n, firstidx, rehash;
+ xInternAtomReq *req;
+
+ /* look in the cache first */
+ if (!(atoms = dpy->atoms)) {
+ dpy->atoms = atoms = (AtomTable *)Xcalloc(1, sizeof(AtomTable));
+ dpy->free_funcs->atoms = _XFreeAtomTable;
+ }
+ sig = 0;
+ for (s1 = (char *)name; (c = *s1++); )
+ sig += c;
+ n = s1 - (char *)name - 1;
+ if (atoms) {
+ firstidx = idx = HASH(sig);
+ while ((e = atoms->table[idx])) {
+ if (e != RESERVED && e->sig == sig) {
+ for (i = n, s1 = (char *)name, s2 = EntryName(e); --i >= 0; ) {
+ if (*s1++ != *s2++)
+ goto nomatch;
+ }
+ if (!*s2)
+ return e->atom;
+ }
+nomatch: if (idx == firstidx)
+ rehash = REHASHVAL(sig);
+ idx = REHASH(idx, rehash);
+ if (idx == firstidx)
+ break;
+ }
+ }
+ *psig = sig;
+ *pidx = idx;
+ if (atoms && !atoms->table[idx])
+ atoms->table[idx] = RESERVED; /* reserve slot */
+ *pn = n;
+ /* not found, go to the server */
+ GetReq(InternAtom, req);
+ req->nbytes = n;
+ req->onlyIfExists = onlyIfExists;
+ req->length += (n+3)>>2;
+ Data(dpy, name, n);
+ return None;
+}
+
+void
+_XUpdateAtomCache(dpy, name, atom, sig, idx, n)
+ Display *dpy;
+ char *name;
+ Atom atom;
+ unsigned long sig;
+ int idx;
+ int n;
+{
+ Entry e, oe;
+ register char *s1;
+ register char c;
+ int firstidx, rehash;
+
+ if (!dpy->atoms) {
+ if (idx < 0) {
+ dpy->atoms = (AtomTable *)Xcalloc(1, sizeof(AtomTable));
+ dpy->free_funcs->atoms = _XFreeAtomTable;
+ }
+ if (!dpy->atoms)
+ return;
+ }
+ if (!sig) {
+ for (s1 = (char *)name; (c = *s1++); )
+ sig += c;
+ n = s1 - (char *)name - 1;
+ if (idx < 0) {
+ firstidx = idx = HASH(sig);
+ if (dpy->atoms->table[idx]) {
+ rehash = REHASHVAL(sig);
+ do
+ idx = REHASH(idx, rehash);
+ while (idx != firstidx && dpy->atoms->table[idx]);
+ }
+ }
+ }
+ e = (Entry)Xmalloc(sizeof(EntryRec) + n + 1);
+ if (e) {
+ e->sig = sig;
+ e->atom = atom;
+ strcpy(EntryName(e), name);
+ if ((oe = dpy->atoms->table[idx]) && (oe != RESERVED))
+ Xfree((char *)oe);
+ dpy->atoms->table[idx] = e;
+ }
+}
+
+#if NeedFunctionPrototypes
+Atom XInternAtom (
+ Display *dpy,
+ _Xconst char *name,
+ Bool onlyIfExists)
+#else
+Atom XInternAtom (dpy, name, onlyIfExists)
+ Display *dpy;
+ char *name;
+ Bool onlyIfExists;
+#endif
+{
+ Atom atom;
+ unsigned long sig;
+ int idx, n;
+ xInternAtomReply rep;
+
+ if (!name)
+ name = "";
+ LockDisplay(dpy);
+ if ((atom = _XInternAtom(dpy, name, onlyIfExists, &sig, &idx, &n))) {
+ UnlockDisplay(dpy);
+ return atom;
+ }
+ if (dpy->atoms && dpy->atoms->table[idx] == RESERVED)
+ dpy->atoms->table[idx] = NULL; /* unreserve slot */
+ if (_XReply (dpy, (xReply *)&rep, 0, xTrue)) {
+ if ((atom = rep.atom))
+ _XUpdateAtomCache(dpy, name, atom, sig, idx, n);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (rep.atom);
+}
+
+typedef struct {
+ unsigned long start_seq;
+ unsigned long stop_seq;
+ char **names;
+ Atom *atoms;
+ int count;
+ Status status;
+} _XIntAtomState;
+
+static
+Bool _XIntAtomHandler(dpy, rep, buf, len, data)
+ register Display *dpy;
+ register xReply *rep;
+ char *buf;
+ int len;
+ XPointer data;
+{
+ register _XIntAtomState *state;
+ register int i, idx;
+ xInternAtomReply replbuf;
+ register xInternAtomReply *repl;
+
+ state = (_XIntAtomState *)data;
+ if (dpy->last_request_read < state->start_seq ||
+ dpy->last_request_read > state->stop_seq)
+ return False;
+ for (i = 0; i < state->count; i++) {
+ if (state->atoms[i] & 0x80000000) {
+ idx = ~state->atoms[i];
+ state->atoms[i] = None;
+ break;
+ }
+ }
+ if (i >= state->count)
+ return False;
+ if (rep->generic.type == X_Error) {
+ state->status = 0;
+ return False;
+ }
+ repl = (xInternAtomReply *)
+ _XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len,
+ (SIZEOF(xInternAtomReply) - SIZEOF(xReply)) >> 2,
+ True);
+ if ((state->atoms[i] = repl->atom))
+ _XUpdateAtomCache(dpy, state->names[i], (Atom) repl->atom,
+ (unsigned long)0, idx, 0);
+ return True;
+}
+
+Status
+XInternAtoms (dpy, names, count, onlyIfExists, atoms_return)
+ Display *dpy;
+ char **names;
+ int count;
+ Bool onlyIfExists;
+ Atom *atoms_return;
+{
+ int i, idx, n, tidx;
+ unsigned long sig;
+ _XAsyncHandler async;
+ _XIntAtomState async_state;
+ int missed = -1;
+ xInternAtomReply rep;
+
+ LockDisplay(dpy);
+ async_state.start_seq = dpy->request + 1;
+ async_state.atoms = atoms_return;
+ async_state.names = names;
+ async_state.count = count - 1;
+ async_state.status = 1;
+ async.next = dpy->async_handlers;
+ async.handler = _XIntAtomHandler;
+ async.data = (XPointer)&async_state;
+ dpy->async_handlers = &async;
+ for (i = 0; i < count; i++) {
+ if (!(atoms_return[i] = _XInternAtom(dpy, names[i], onlyIfExists,
+ &sig, &idx, &n))) {
+ missed = i;
+ atoms_return[i] = ~((Atom)idx);
+ async_state.stop_seq = dpy->request;
+ }
+ }
+ if (missed >= 0) {
+ if (dpy->atoms) {
+ /* unreserve anything we just reserved */
+ for (i = 0; i < count; i++) {
+ if (atoms_return[i] & 0x80000000) {
+ tidx = ~atoms_return[i];
+ if (dpy->atoms->table[tidx] == RESERVED)
+ dpy->atoms->table[tidx] = NULL;
+ }
+ }
+ }
+ if (_XReply (dpy, (xReply *)&rep, 0, xTrue)) {
+ if ((atoms_return[missed] = rep.atom))
+ _XUpdateAtomCache(dpy, names[missed], (Atom) rep.atom,
+ sig, idx, n);
+ } else {
+ atoms_return[missed] = None;
+ async_state.status = 0;
+ }
+ }
+ DeqAsyncHandler(dpy, &async);
+ UnlockDisplay(dpy);
+ if (missed >= 0)
+ SyncHandle();
+ return async_state.status;
+}
diff --git a/src/KeyBind.c b/src/KeyBind.c
new file mode 100644
index 00000000..f56a06a4
--- /dev/null
+++ b/src/KeyBind.c
@@ -0,0 +1,731 @@
+/* $Xorg: KeyBind.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1985, 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/* Beware, here be monsters (still under construction... - JG */
+
+#define NEED_EVENTS
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+#define XK_MISCELLANY
+#define XK_LATIN1
+#define XK_LATIN2
+#define XK_LATIN3
+#define XK_LATIN4
+#define XK_CYRILLIC
+#define XK_GREEK
+#define XK_XKB_KEYS
+#include <X11/keysymdef.h>
+#include <stdio.h>
+
+#ifdef USE_OWN_COMPOSE
+#include "imComp.h"
+#endif
+
+#ifdef XKB
+#define XKeycodeToKeysym _XKeycodeToKeysym
+#define XKeysymToKeycode _XKeysymToKeycode
+#define XLookupKeysym _XLookupKeysym
+#define XRefreshKeyboardMapping _XRefreshKeyboardMapping
+#define XLookupString _XLookupString
+#else
+#define XkbKeysymToModifiers _XKeysymToModifiers
+#endif
+
+#define AllMods (ShiftMask|LockMask|ControlMask| \
+ Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)
+
+static void ComputeMaskFromKeytrans();
+
+struct _XKeytrans {
+ struct _XKeytrans *next;/* next on list */
+ char *string; /* string to return when the time comes */
+ int len; /* length of string (since NULL is legit)*/
+ KeySym key; /* keysym rebound */
+ unsigned int state; /* modifier state */
+ KeySym *modifiers; /* modifier keysyms you want */
+ int mlen; /* length of modifier list */
+};
+
+static KeySym
+#if NeedFunctionPrototypes
+KeyCodetoKeySym(register Display *dpy, KeyCode keycode, int col)
+#else
+KeyCodetoKeySym(dpy, keycode, col)
+ register Display *dpy;
+ KeyCode keycode;
+ int col;
+#endif
+{
+ register int per = dpy->keysyms_per_keycode;
+ register KeySym *syms;
+ KeySym lsym, usym;
+
+ if ((col < 0) || ((col >= per) && (col > 3)) ||
+ ((int)keycode < dpy->min_keycode) || ((int)keycode > dpy->max_keycode))
+ return NoSymbol;
+
+ syms = &dpy->keysyms[(keycode - dpy->min_keycode) * per];
+ if (col < 4) {
+ if (col > 1) {
+ while ((per > 2) && (syms[per - 1] == NoSymbol))
+ per--;
+ if (per < 3)
+ col -= 2;
+ }
+ if ((per <= (col|1)) || (syms[col|1] == NoSymbol)) {
+ XConvertCase(syms[col&~1], &lsym, &usym);
+ if (!(col & 1))
+ return lsym;
+ else if (usym == lsym)
+ return NoSymbol;
+ else
+ return usym;
+ }
+ }
+ return syms[col];
+}
+
+#if NeedFunctionPrototypes
+KeySym
+XKeycodeToKeysym(Display *dpy,
+#if NeedWidePrototypes
+ unsigned int kc,
+#else
+ KeyCode kc,
+#endif
+ int col)
+#else
+KeySym
+XKeycodeToKeysym(dpy, kc, col)
+ Display *dpy;
+ KeyCode kc;
+ int col;
+#endif
+{
+ if ((! dpy->keysyms) && (! _XKeyInitialize(dpy)))
+ return NoSymbol;
+ return KeyCodetoKeySym(dpy, kc, col);
+}
+
+KeyCode
+XKeysymToKeycode(dpy, ks)
+ Display *dpy;
+ KeySym ks;
+{
+ register int i, j;
+
+ if ((! dpy->keysyms) && (! _XKeyInitialize(dpy)))
+ return (KeyCode) 0;
+ for (j = 0; j < dpy->keysyms_per_keycode; j++) {
+ for (i = dpy->min_keycode; i <= dpy->max_keycode; i++) {
+ if (KeyCodetoKeySym(dpy, (KeyCode) i, j) == ks)
+ return i;
+ }
+ }
+ return 0;
+}
+
+KeySym
+XLookupKeysym(event, col)
+ register XKeyEvent *event;
+ int col;
+{
+ if ((! event->display->keysyms) && (! _XKeyInitialize(event->display)))
+ return NoSymbol;
+ return KeyCodetoKeySym(event->display, event->keycode, col);
+}
+
+static void
+ResetModMap(dpy)
+ Display *dpy;
+{
+ register XModifierKeymap *map;
+ register int i, j, n;
+ KeySym sym;
+ register struct _XKeytrans *p;
+
+ map = dpy->modifiermap;
+ /* If any Lock key contains Caps_Lock, then interpret as Caps_Lock,
+ * else if any contains Shift_Lock, then interpret as Shift_Lock,
+ * else ignore Lock altogether.
+ */
+ dpy->lock_meaning = NoSymbol;
+ /* Lock modifiers are in the second row of the matrix */
+ n = 2 * map->max_keypermod;
+ for (i = map->max_keypermod; i < n; i++) {
+ for (j = 0; j < dpy->keysyms_per_keycode; j++) {
+ sym = KeyCodetoKeySym(dpy, map->modifiermap[i], j);
+ if (sym == XK_Caps_Lock) {
+ dpy->lock_meaning = XK_Caps_Lock;
+ break;
+ } else if (sym == XK_Shift_Lock) {
+ dpy->lock_meaning = XK_Shift_Lock;
+ }
+ else if (sym == XK_ISO_Lock) {
+ dpy->lock_meaning = XK_Caps_Lock;
+ break;
+ }
+ }
+ }
+ /* Now find any Mod<n> modifier acting as the Group or Numlock modifier */
+ dpy->mode_switch = 0;
+ dpy->num_lock = 0;
+ n *= 4;
+ for (i = 3*map->max_keypermod; i < n; i++) {
+ for (j = 0; j < dpy->keysyms_per_keycode; j++) {
+ sym = KeyCodetoKeySym(dpy, map->modifiermap[i], j);
+ if (sym == XK_Mode_switch)
+ dpy->mode_switch |= 1 << (i / map->max_keypermod);
+ if (sym == XK_Num_Lock)
+ dpy->num_lock |= 1 << (i / map->max_keypermod);
+ }
+ }
+ for (p = dpy->key_bindings; p; p = p->next)
+ ComputeMaskFromKeytrans(dpy, p);
+}
+
+static int
+InitModMap(dpy)
+ Display *dpy;
+{
+ register XModifierKeymap *map;
+
+ if (! (map = XGetModifierMapping(dpy)))
+ return 0;
+ LockDisplay(dpy);
+ if (dpy->modifiermap)
+ XFreeModifiermap(dpy->modifiermap);
+ dpy->modifiermap = map;
+ dpy->free_funcs->modifiermap = XFreeModifiermap;
+ if (dpy->keysyms)
+ ResetModMap(dpy);
+ UnlockDisplay(dpy);
+ return 1;
+}
+
+XRefreshKeyboardMapping(event)
+ register XMappingEvent *event;
+{
+
+ if(event->request == MappingKeyboard) {
+ /* XXX should really only refresh what is necessary
+ * for now, make initialize test fail
+ */
+ LockDisplay(event->display);
+ if (event->display->keysyms) {
+ Xfree ((char *)event->display->keysyms);
+ event->display->keysyms = NULL;
+ }
+ UnlockDisplay(event->display);
+ }
+ if(event->request == MappingModifier) {
+ LockDisplay(event->display);
+ if (event->display->modifiermap) {
+ XFreeModifiermap(event->display->modifiermap);
+ event->display->modifiermap = NULL;
+ }
+ UnlockDisplay(event->display);
+ /* go ahead and get it now, since initialize test may not fail */
+ if (event->display->keysyms)
+ (void) InitModMap(event->display);
+ }
+ return 1;
+}
+
+int
+_XKeyInitialize(dpy)
+ Display *dpy;
+{
+ int per, n;
+ KeySym *keysyms;
+
+ /*
+ * lets go get the keysyms from the server.
+ */
+ if (!dpy->keysyms) {
+ n = dpy->max_keycode - dpy->min_keycode + 1;
+ keysyms = XGetKeyboardMapping (dpy, (KeyCode) dpy->min_keycode,
+ n, &per);
+ /* keysyms may be NULL */
+ if (! keysyms) return 0;
+
+ LockDisplay(dpy);
+ if (dpy->keysyms)
+ Xfree ((char *)dpy->keysyms);
+ dpy->keysyms = keysyms;
+ dpy->keysyms_per_keycode = per;
+ if (dpy->modifiermap)
+ ResetModMap(dpy);
+ UnlockDisplay(dpy);
+ }
+ if (!dpy->modifiermap)
+ return InitModMap(dpy);
+ return 1;
+}
+
+void
+XConvertCase(sym, lower, upper)
+ register KeySym sym;
+ KeySym *lower;
+ KeySym *upper;
+{
+ *lower = sym;
+ *upper = sym;
+ switch(sym >> 8) {
+ case 0: /* Latin 1 */
+ if ((sym >= XK_A) && (sym <= XK_Z))
+ *lower += (XK_a - XK_A);
+ else if ((sym >= XK_a) && (sym <= XK_z))
+ *upper -= (XK_a - XK_A);
+ else if ((sym >= XK_Agrave) && (sym <= XK_Odiaeresis))
+ *lower += (XK_agrave - XK_Agrave);
+ else if ((sym >= XK_agrave) && (sym <= XK_odiaeresis))
+ *upper -= (XK_agrave - XK_Agrave);
+ else if ((sym >= XK_Ooblique) && (sym <= XK_Thorn))
+ *lower += (XK_oslash - XK_Ooblique);
+ else if ((sym >= XK_oslash) && (sym <= XK_thorn))
+ *upper -= (XK_oslash - XK_Ooblique);
+ break;
+ case 1: /* Latin 2 */
+ /* Assume the KeySym is a legal value (ignore discontinuities) */
+ if (sym == XK_Aogonek)
+ *lower = XK_aogonek;
+ else if (sym >= XK_Lstroke && sym <= XK_Sacute)
+ *lower += (XK_lstroke - XK_Lstroke);
+ else if (sym >= XK_Scaron && sym <= XK_Zacute)
+ *lower += (XK_scaron - XK_Scaron);
+ else if (sym >= XK_Zcaron && sym <= XK_Zabovedot)
+ *lower += (XK_zcaron - XK_Zcaron);
+ else if (sym == XK_aogonek)
+ *upper = XK_Aogonek;
+ else if (sym >= XK_lstroke && sym <= XK_sacute)
+ *upper -= (XK_lstroke - XK_Lstroke);
+ else if (sym >= XK_scaron && sym <= XK_zacute)
+ *upper -= (XK_scaron - XK_Scaron);
+ else if (sym >= XK_zcaron && sym <= XK_zabovedot)
+ *upper -= (XK_zcaron - XK_Zcaron);
+ else if (sym >= XK_Racute && sym <= XK_Tcedilla)
+ *lower += (XK_racute - XK_Racute);
+ else if (sym >= XK_racute && sym <= XK_tcedilla)
+ *upper -= (XK_racute - XK_Racute);
+ break;
+ case 2: /* Latin 3 */
+ /* Assume the KeySym is a legal value (ignore discontinuities) */
+ if (sym >= XK_Hstroke && sym <= XK_Hcircumflex)
+ *lower += (XK_hstroke - XK_Hstroke);
+ else if (sym >= XK_Gbreve && sym <= XK_Jcircumflex)
+ *lower += (XK_gbreve - XK_Gbreve);
+ else if (sym >= XK_hstroke && sym <= XK_hcircumflex)
+ *upper -= (XK_hstroke - XK_Hstroke);
+ else if (sym >= XK_gbreve && sym <= XK_jcircumflex)
+ *upper -= (XK_gbreve - XK_Gbreve);
+ else if (sym >= XK_Cabovedot && sym <= XK_Scircumflex)
+ *lower += (XK_cabovedot - XK_Cabovedot);
+ else if (sym >= XK_cabovedot && sym <= XK_scircumflex)
+ *upper -= (XK_cabovedot - XK_Cabovedot);
+ break;
+ case 3: /* Latin 4 */
+ /* Assume the KeySym is a legal value (ignore discontinuities) */
+ if (sym >= XK_Rcedilla && sym <= XK_Tslash)
+ *lower += (XK_rcedilla - XK_Rcedilla);
+ else if (sym >= XK_rcedilla && sym <= XK_tslash)
+ *upper -= (XK_rcedilla - XK_Rcedilla);
+ else if (sym == XK_ENG)
+ *lower = XK_eng;
+ else if (sym == XK_eng)
+ *upper = XK_ENG;
+ else if (sym >= XK_Amacron && sym <= XK_Umacron)
+ *lower += (XK_amacron - XK_Amacron);
+ else if (sym >= XK_amacron && sym <= XK_umacron)
+ *upper -= (XK_amacron - XK_Amacron);
+ break;
+ case 6: /* Cyrillic */
+ /* Assume the KeySym is a legal value (ignore discontinuities) */
+ if (sym >= XK_Serbian_DJE && sym <= XK_Serbian_DZE)
+ *lower -= (XK_Serbian_DJE - XK_Serbian_dje);
+ else if (sym >= XK_Serbian_dje && sym <= XK_Serbian_dze)
+ *upper += (XK_Serbian_DJE - XK_Serbian_dje);
+ else if (sym >= XK_Cyrillic_YU && sym <= XK_Cyrillic_HARDSIGN)
+ *lower -= (XK_Cyrillic_YU - XK_Cyrillic_yu);
+ else if (sym >= XK_Cyrillic_yu && sym <= XK_Cyrillic_hardsign)
+ *upper += (XK_Cyrillic_YU - XK_Cyrillic_yu);
+ break;
+ case 7: /* Greek */
+ /* Assume the KeySym is a legal value (ignore discontinuities) */
+ if (sym >= XK_Greek_ALPHAaccent && sym <= XK_Greek_OMEGAaccent)
+ *lower += (XK_Greek_alphaaccent - XK_Greek_ALPHAaccent);
+ else if (sym >= XK_Greek_alphaaccent && sym <= XK_Greek_omegaaccent &&
+ sym != XK_Greek_iotaaccentdieresis &&
+ sym != XK_Greek_upsilonaccentdieresis)
+ *upper -= (XK_Greek_alphaaccent - XK_Greek_ALPHAaccent);
+ else if (sym >= XK_Greek_ALPHA && sym <= XK_Greek_OMEGA)
+ *lower += (XK_Greek_alpha - XK_Greek_ALPHA);
+ else if (sym >= XK_Greek_alpha && sym <= XK_Greek_omega &&
+ sym != XK_Greek_finalsmallsigma)
+ *upper -= (XK_Greek_alpha - XK_Greek_ALPHA);
+ break;
+ }
+}
+
+int
+#if NeedFunctionPrototypes
+_XTranslateKey( register Display *dpy,
+ KeyCode keycode,
+ register unsigned int modifiers,
+ unsigned int *modifiers_return,
+ KeySym *keysym_return)
+#else
+_XTranslateKey(dpy, keycode, modifiers, modifiers_return, keysym_return)
+ register Display *dpy;
+ KeyCode keycode;
+ register unsigned int modifiers;
+ unsigned int *modifiers_return;
+ KeySym *keysym_return;
+#endif
+{
+ int per;
+ register KeySym *syms;
+ KeySym sym, lsym, usym;
+
+ if ((! dpy->keysyms) && (! _XKeyInitialize(dpy)))
+ return 0;
+ *modifiers_return = ((ShiftMask|LockMask)
+ | dpy->mode_switch | dpy->num_lock);
+ if (((int)keycode < dpy->min_keycode) || ((int)keycode > dpy->max_keycode))
+ {
+ *keysym_return = NoSymbol;
+ return 1;
+ }
+ per = dpy->keysyms_per_keycode;
+ syms = &dpy->keysyms[(keycode - dpy->min_keycode) * per];
+ while ((per > 2) && (syms[per - 1] == NoSymbol))
+ per--;
+ if ((per > 2) && (modifiers & dpy->mode_switch)) {
+ syms += 2;
+ per -= 2;
+ }
+ if ((modifiers & dpy->num_lock) &&
+ (per > 1 && (IsKeypadKey(syms[1]) || IsPrivateKeypadKey(syms[1])))) {
+ if ((modifiers & ShiftMask) ||
+ ((modifiers & LockMask) && (dpy->lock_meaning == XK_Shift_Lock)))
+ *keysym_return = syms[0];
+ else
+ *keysym_return = syms[1];
+ } else if (!(modifiers & ShiftMask) &&
+ (!(modifiers & LockMask) || (dpy->lock_meaning == NoSymbol))) {
+ if ((per == 1) || (syms[1] == NoSymbol))
+ XConvertCase(syms[0], keysym_return, &usym);
+ else
+ *keysym_return = syms[0];
+ } else if (!(modifiers & LockMask) ||
+ (dpy->lock_meaning != XK_Caps_Lock)) {
+ if ((per == 1) || ((usym = syms[1]) == NoSymbol))
+ XConvertCase(syms[0], &lsym, &usym);
+ *keysym_return = usym;
+ } else {
+ if ((per == 1) || ((sym = syms[1]) == NoSymbol))
+ sym = syms[0];
+ XConvertCase(sym, &lsym, &usym);
+ if (!(modifiers & ShiftMask) && (sym != syms[0]) &&
+ ((sym != usym) || (lsym == usym)))
+ XConvertCase(syms[0], &lsym, &usym);
+ *keysym_return = usym;
+ }
+ if (*keysym_return == XK_VoidSymbol)
+ *keysym_return = NoSymbol;
+ return 1;
+}
+
+int
+_XTranslateKeySym(dpy, symbol, modifiers, buffer, nbytes)
+ Display *dpy;
+ register KeySym symbol;
+ unsigned int modifiers;
+ char *buffer;
+ int nbytes;
+{
+ register struct _XKeytrans *p;
+ int length;
+ unsigned long hiBytes;
+ register unsigned char c;
+
+ if (!symbol)
+ return 0;
+ /* see if symbol rebound, if so, return that string. */
+ for (p = dpy->key_bindings; p; p = p->next) {
+ if (((modifiers & AllMods) == p->state) && (symbol == p->key)) {
+ length = p->len;
+ if (length > nbytes) length = nbytes;
+ memcpy (buffer, p->string, length);
+ return length;
+ }
+ }
+ /* try to convert to Latin-1, handling control */
+ hiBytes = symbol >> 8;
+ if (!(nbytes &&
+ ((hiBytes == 0) ||
+ ((hiBytes == 0xFF) &&
+ (((symbol >= XK_BackSpace) && (symbol <= XK_Clear)) ||
+ (symbol == XK_Return) ||
+ (symbol == XK_Escape) ||
+ (symbol == XK_KP_Space) ||
+ (symbol == XK_KP_Tab) ||
+ (symbol == XK_KP_Enter) ||
+ ((symbol >= XK_KP_Multiply) && (symbol <= XK_KP_9)) ||
+ (symbol == XK_KP_Equal) ||
+ (symbol == XK_Delete))))))
+ return 0;
+
+ /* if X keysym, convert to ascii by grabbing low 7 bits */
+ if (symbol == XK_KP_Space)
+ c = XK_space & 0x7F; /* patch encoding botch */
+ else if (hiBytes == 0xFF)
+ c = symbol & 0x7F;
+ else
+ c = symbol & 0xFF;
+ /* only apply Control key if it makes sense, else ignore it */
+ if (modifiers & ControlMask) {
+ if ((c >= '@' && c < '\177') || c == ' ') c &= 0x1F;
+ else if (c == '2') c = '\000';
+ else if (c >= '3' && c <= '7') c -= ('3' - '\033');
+ else if (c == '8') c = '\177';
+ else if (c == '/') c = '_' & 0x1F;
+ }
+ buffer[0] = c;
+ return 1;
+}
+
+/*ARGSUSED*/
+int
+XLookupString (event, buffer, nbytes, keysym, status)
+ register XKeyEvent *event;
+ char *buffer; /* buffer */
+ int nbytes; /* space in buffer for characters */
+ KeySym *keysym;
+ XComposeStatus *status; /* not implemented */
+{
+ unsigned int modifiers;
+ KeySym symbol;
+
+ if (! _XTranslateKey(event->display, event->keycode, event->state,
+ &modifiers, &symbol))
+ return 0;
+
+#ifdef USE_OWN_COMPOSE
+ if ( status ) {
+ static int been_here= 0;
+ if ( !been_here ) {
+ XimCompInitTables();
+ been_here = 1;
+ }
+ if ( !XimCompLegalStatus(status) ) {
+ status->compose_ptr = NULL;
+ status->chars_matched = 0;
+ }
+ if ( ((status->chars_matched>0)&&(status->compose_ptr!=NULL)) ||
+ XimCompIsComposeKey(symbol,event->keycode,status) ) {
+ XimCompRtrn rtrn;
+ switch (XimCompProcessSym(status,symbol,&rtrn)) {
+ case XIM_COMP_IGNORE:
+ break;
+ case XIM_COMP_IN_PROGRESS:
+ if ( keysym!=NULL )
+ *keysym = NoSymbol;
+ return 0;
+ case XIM_COMP_FAIL:
+ {
+ int n = 0, len= 0;
+ for (n=len=0;rtrn.sym[n]!=XK_VoidSymbol;n++) {
+ if ( nbytes-len > 0 ) {
+ len+= _XTranslateKeySym(event->display,rtrn.sym[n],
+ event->state,
+ buffer+len,nbytes-len);
+ }
+ }
+ if ( keysym!=NULL ) {
+ if ( n==1 ) *keysym = rtrn.sym[0];
+ else *keysym = NoSymbol;
+ }
+ return len;
+ }
+ case XIM_COMP_SUCCEED:
+ {
+ int len,n = 0;
+
+ symbol = rtrn.matchSym;
+ if ( keysym!=NULL ) *keysym = symbol;
+ if ( rtrn.str[0]!='\0' ) {
+ strncpy(buffer,rtrn.str,nbytes-1);
+ buffer[nbytes-1]= '\0';
+ len = strlen(buffer);
+ }
+ else {
+ len = _XTranslateKeySym(event->display,symbol,
+ event->state,
+ buffer,nbytes);
+ }
+ for (n=0;rtrn.sym[n]!=XK_VoidSymbol;n++) {
+ if ( nbytes-len > 0 ) {
+ len+= _XTranslateKeySym(event->display,rtrn.sym[n],
+ event->state,
+ buffer+len,nbytes-len);
+ }
+ }
+ return len;
+ }
+ }
+ }
+ }
+#endif
+
+ if (keysym)
+ *keysym = symbol;
+ /* arguable whether to use (event->state & ~modifiers) here */
+ return _XTranslateKeySym(event->display, symbol, event->state,
+ buffer, nbytes);
+}
+
+static void
+_XFreeKeyBindings (dpy)
+ Display *dpy;
+{
+ register struct _XKeytrans *p, *np;
+
+ for (p = dpy->key_bindings; p; p = np) {
+ np = p->next;
+ Xfree(p->string);
+ Xfree((char *)p->modifiers);
+ Xfree((char *)p);
+ }
+}
+
+#if NeedFunctionPrototypes
+XRebindKeysym (
+ Display *dpy,
+ KeySym keysym,
+ KeySym *mlist,
+ int nm, /* number of modifiers in mlist */
+ _Xconst unsigned char *str,
+ int nbytes)
+#else
+XRebindKeysym (dpy, keysym, mlist, nm, str, nbytes)
+ Display *dpy;
+ KeySym keysym;
+ KeySym *mlist;
+ int nm; /* number of modifiers in mlist */
+ unsigned char *str;
+ int nbytes;
+#endif
+{
+ register struct _XKeytrans *tmp, *p;
+ int nb;
+
+ if ((! dpy->keysyms) && (! _XKeyInitialize(dpy)))
+ return 0;
+ LockDisplay(dpy);
+ tmp = dpy->key_bindings;
+ nb = sizeof(KeySym) * nm;
+
+ if ((! (p = (struct _XKeytrans *) Xmalloc( sizeof(struct _XKeytrans)))) ||
+ ((! (p->string = (char *) Xmalloc( (unsigned) nbytes))) &&
+ (nbytes > 0)) ||
+ ((! (p->modifiers = (KeySym *) Xmalloc( (unsigned) nb))) &&
+ (nb > 0))) {
+ if (p) {
+ if (p->string) Xfree(p->string);
+ if (p->modifiers) Xfree((char *) p->modifiers);
+ Xfree((char *) p);
+ }
+ UnlockDisplay(dpy);
+ return 0;
+ }
+
+ dpy->key_bindings = p;
+ dpy->free_funcs->key_bindings = _XFreeKeyBindings;
+ p->next = tmp; /* chain onto list */
+ memcpy (p->string, (char *) str, nbytes);
+ p->len = nbytes;
+ memcpy ((char *) p->modifiers, (char *) mlist, nb);
+ p->key = keysym;
+ p->mlen = nm;
+ ComputeMaskFromKeytrans(dpy, p);
+ UnlockDisplay(dpy);
+ return 0;
+}
+
+unsigned
+_XKeysymToModifiers(dpy,ks)
+ Display *dpy;
+ KeySym ks;
+{
+ CARD8 code,mods;
+ register KeySym *kmax;
+ register KeySym *k;
+ register XModifierKeymap *m;
+
+ if ((! dpy->keysyms) && (! _XKeyInitialize(dpy)))
+ return 0;
+ kmax = dpy->keysyms +
+ (dpy->max_keycode - dpy->min_keycode + 1) * dpy->keysyms_per_keycode;
+ k = dpy->keysyms;
+ m = dpy->modifiermap;
+ mods= 0;
+ while (k<kmax) {
+ if (*k == ks ) {
+ register int j = m->max_keypermod<<3;
+
+ code=(((k-dpy->keysyms)/dpy->keysyms_per_keycode)+dpy->min_keycode);
+
+ while (--j >= 0) {
+ if (code == m->modifiermap[j])
+ mods|= (1<<(j/m->max_keypermod));
+ }
+ }
+ k++;
+ }
+ return mods;
+}
+
+/*
+ * given a list of modifiers, computes the mask necessary for later matching.
+ * This routine must lookup the key in the Keymap and then search to see
+ * what modifier it is bound to, if any. Sets the AnyModifier bit if it
+ * can't map some keysym to a modifier.
+ */
+static void
+ComputeMaskFromKeytrans(dpy, p)
+ Display *dpy;
+ register struct _XKeytrans *p;
+{
+ register int i;
+
+ p->state = AnyModifier;
+ for (i = 0; i < p->mlen; i++) {
+ p->state|= XkbKeysymToModifiers(dpy,p->modifiers[i]);
+ }
+ p->state &= AllMods;
+}
diff --git a/src/KeysymStr.c b/src/KeysymStr.c
new file mode 100644
index 00000000..1e94a5d7
--- /dev/null
+++ b/src/KeysymStr.c
@@ -0,0 +1,137 @@
+/* $Xorg: KeysymStr.c,v 1.5 2001/02/09 02:03:34 xorgcvs Exp $ */
+
+/*
+
+Copyright 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+#include <X11/Xresource.h>
+#include <X11/keysymdef.h>
+
+#ifdef __STDC__
+#define Const const
+#else
+#define Const /**/
+#endif
+
+typedef unsigned long Signature;
+
+#define NEEDVTABLE
+#include "ks_tables.h"
+
+extern XrmDatabase _XInitKeysymDB();
+extern Const unsigned char _XkeyTable[];
+
+
+typedef struct _GRNData {
+ char *name;
+ XrmRepresentation type;
+ XrmValuePtr value;
+} GRNData;
+
+#if NeedFunctionPrototypes
+/*ARGSUSED*/
+static Bool SameValue(
+ XrmDatabase* db,
+ XrmBindingList bindings,
+ XrmQuarkList quarks,
+ XrmRepresentation* type,
+ XrmValuePtr value,
+ XPointer data
+)
+#else
+static Bool SameValue(db, bindings, quarks, type, value, data)
+ XrmDatabase *db;
+ XrmBindingList bindings;
+ XrmQuarkList quarks;
+ XrmRepresentation *type;
+ XrmValuePtr value;
+ XPointer data;
+#endif
+{
+ GRNData *gd = (GRNData *)data;
+
+ if ((*type == gd->type) && (value->size == gd->value->size) &&
+ !strncmp((char *)value->addr, (char *)gd->value->addr, value->size))
+ {
+ gd->name = XrmQuarkToString(*quarks); /* XXX */
+ return True;
+ }
+ return False;
+}
+
+char *XKeysymToString(ks)
+ KeySym ks;
+{
+ register int i, n;
+ int h;
+ register int idx;
+ Const unsigned char *entry;
+ unsigned char val1, val2;
+ XrmDatabase keysymdb;
+
+ if (!ks || (ks & ((unsigned long) ~0x1fffffff)) != 0)
+ return ((char *)NULL);
+ if (ks == XK_VoidSymbol)
+ ks = 0;
+ if (ks <= 0xffff)
+ {
+ val1 = ks >> 8;
+ val2 = ks & 0xff;
+ i = ks % VTABLESIZE;
+ h = i + 1;
+ n = VMAXHASH;
+ while ((idx = hashKeysym[i]))
+ {
+ entry = &_XkeyTable[idx];
+ if ((entry[0] == val1) && (entry[1] == val2))
+ return ((char *)entry + 2);
+ if (!--n)
+ break;
+ i += h;
+ if (i >= VTABLESIZE)
+ i -= VTABLESIZE;
+ }
+ }
+
+ if ((keysymdb = _XInitKeysymDB()))
+ {
+ char buf[9];
+ XrmValue resval;
+ XrmQuark empty = NULLQUARK;
+ GRNData data;
+
+ sprintf(buf, "%lX", ks);
+ resval.addr = (XPointer)buf;
+ resval.size = strlen(buf) + 1;
+ data.name = (char *)NULL;
+ data.type = XrmPermStringToQuark("String");
+ data.value = &resval;
+ (void)XrmEnumerateDatabase(keysymdb, &empty, &empty, XrmEnumAllLevels,
+ SameValue, (XPointer)&data);
+ return data.name;
+ }
+ return ((char *) NULL);
+}
diff --git a/src/KillCl.c b/src/KillCl.c
new file mode 100644
index 00000000..750ea825
--- /dev/null
+++ b/src/KillCl.c
@@ -0,0 +1,41 @@
+/* $Xorg: KillCl.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XKillClient(dpy, resource)
+ register Display *dpy;
+ XID resource;
+{
+ register xResourceReq *req;
+ LockDisplay(dpy);
+ GetResReq(KillClient, resource, req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/LiHosts.c b/src/LiHosts.c
new file mode 100644
index 00000000..2f22d71d
--- /dev/null
+++ b/src/LiHosts.c
@@ -0,0 +1,100 @@
+/* $Xorg: LiHosts.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/* This can really be considered an os dependent routine */
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+/*
+ * can be freed using XFree.
+ */
+
+XHostAddress *XListHosts (dpy, nhosts, enabled)
+ register Display *dpy;
+ int *nhosts; /* RETURN */
+ Bool *enabled; /* RETURN */
+ {
+ register XHostAddress *outbuf = 0, *op;
+ xListHostsReply reply;
+ long nbytes;
+ unsigned char *buf, *bp;
+ register unsigned i;
+ register xListHostsReq *req;
+
+ *nhosts = 0;
+ LockDisplay(dpy);
+ GetReq (ListHosts, req);
+
+ if (!_XReply (dpy, (xReply *) &reply, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XHostAddress *) NULL;
+ }
+
+ if (reply.nHosts) {
+ nbytes = reply.length << 2; /* compute number of bytes in reply */
+ op = outbuf = (XHostAddress *)
+ Xmalloc((unsigned) (nbytes + reply.nHosts * sizeof(XHostAddress)));
+
+ if (! outbuf) {
+ _XEatData(dpy, (unsigned long) nbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XHostAddress *) NULL;
+ }
+ bp = buf =
+ ((unsigned char *) outbuf) + reply.nHosts * sizeof(XHostAddress);
+
+ _XRead (dpy, (char *) buf, nbytes);
+
+ for (i = 0; i < reply.nHosts; i++) {
+#ifdef WORD64
+ xHostEntry xhe;
+ memcpy((char *)&xhe, bp, SIZEOF(xHostEntry));
+ op->family = xhe.family;
+ op->length = xhe.length;
+#else
+ op->family = ((xHostEntry *) bp)->family;
+ op->length =((xHostEntry *) bp)->length;
+#endif
+ op->address = (char *) (bp + SIZEOF(xHostEntry));
+ bp += SIZEOF(xHostEntry) + (((op->length + 3) >> 2) << 2);
+ op++;
+ }
+ }
+
+ *enabled = reply.enabled;
+ *nhosts = reply.nHosts;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (outbuf);
+}
+
+
+
+
+
diff --git a/src/LiICmaps.c b/src/LiICmaps.c
new file mode 100644
index 00000000..93076cc7
--- /dev/null
+++ b/src/LiICmaps.c
@@ -0,0 +1,70 @@
+/* $Xorg: LiICmaps.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+Colormap *XListInstalledColormaps(dpy, win, n)
+register Display *dpy;
+Window win;
+int *n; /* RETURN */
+{
+ long nbytes;
+ Colormap *cmaps;
+ xListInstalledColormapsReply rep;
+ register xResourceReq *req;
+
+ LockDisplay(dpy);
+ GetResReq(ListInstalledColormaps, win, req);
+
+ if(_XReply(dpy, (xReply *) &rep, 0, xFalse) == 0) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ *n = 0;
+ return((Colormap *) NULL);
+ }
+
+ if (rep.nColormaps) {
+ nbytes = rep.nColormaps * sizeof(Colormap);
+ cmaps = (Colormap *) Xmalloc((unsigned) nbytes);
+ nbytes = rep.nColormaps << 2;
+ if (! cmaps) {
+ _XEatData(dpy, (unsigned long) nbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return((Colormap *) NULL);
+ }
+ _XRead32 (dpy, (char *) cmaps, nbytes);
+ }
+ else cmaps = (Colormap *) NULL;
+
+ *n = rep.nColormaps;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(cmaps);
+}
+
diff --git a/src/LiProps.c b/src/LiProps.c
new file mode 100644
index 00000000..ae733d74
--- /dev/null
+++ b/src/LiProps.c
@@ -0,0 +1,68 @@
+/* $Xorg: LiProps.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+Atom *XListProperties(dpy, window, n_props)
+register Display *dpy;
+Window window;
+int *n_props; /* RETURN */
+{
+ long nbytes;
+ xListPropertiesReply rep;
+ Atom *properties;
+ register xResourceReq *req;
+
+ LockDisplay(dpy);
+ GetResReq(ListProperties, window, req);
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ *n_props = 0;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return ((Atom *) NULL);
+ }
+
+ if (rep.nProperties) {
+ nbytes = rep.nProperties * sizeof(Atom);
+ properties = (Atom *) Xmalloc ((unsigned) nbytes);
+ nbytes = rep.nProperties << 2;
+ if (! properties) {
+ _XEatData(dpy, (unsigned long) nbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (Atom *) NULL;
+ }
+ _XRead32 (dpy, (char *) properties, nbytes);
+ }
+ else properties = (Atom *) NULL;
+
+ *n_props = rep.nProperties;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (properties);
+}
diff --git a/src/ListExt.c b/src/ListExt.c
new file mode 100644
index 00000000..6d626be9
--- /dev/null
+++ b/src/ListExt.c
@@ -0,0 +1,96 @@
+/* $Xorg: ListExt.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+char **XListExtensions(dpy, nextensions)
+register Display *dpy;
+int *nextensions; /* RETURN */
+{
+ xListExtensionsReply rep;
+ char **list;
+ char *ch;
+ register unsigned i;
+ register int length;
+ register xReq *req;
+ register long rlen;
+
+ LockDisplay(dpy);
+ GetEmptyReq (ListExtensions, req);
+
+ if (! _XReply (dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (char **) NULL;
+ }
+
+ if (rep.nExtensions) {
+ list = (char **) Xmalloc (
+ (unsigned)(rep.nExtensions * sizeof (char *)));
+ rlen = rep.length << 2;
+ ch = (char *) Xmalloc ((unsigned) rlen + 1);
+ /* +1 to leave room for last null-terminator */
+
+ if ((!list) || (!ch)) {
+ if (list) Xfree((char *) list);
+ if (ch) Xfree((char *) ch);
+ _XEatData(dpy, (unsigned long) rlen);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (char **) NULL;
+ }
+
+ _XReadPad (dpy, ch, rlen);
+ /*
+ * unpack into null terminated strings.
+ */
+ length = *ch;
+ for (i = 0; i < rep.nExtensions; i++) {
+ list[i] = ch+1; /* skip over length */
+ ch += length + 1; /* find next length ... */
+ length = *ch;
+ *ch = '\0'; /* and replace with null-termination */
+ }
+ }
+ else list = (char **) NULL;
+
+ *nextensions = rep.nExtensions;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (list);
+}
+
+XFreeExtensionList (list)
+char **list;
+{
+ if (list != NULL) {
+ Xfree (list[0]-1);
+ Xfree ((char *)list);
+ }
+ return 1;
+}
diff --git a/src/LoadFont.c b/src/LoadFont.c
new file mode 100644
index 00000000..6dd96ad6
--- /dev/null
+++ b/src/LoadFont.c
@@ -0,0 +1,54 @@
+/* $Xorg: LoadFont.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+#if NeedFunctionPrototypes
+Font XLoadFont (
+ register Display *dpy,
+ _Xconst char *name)
+#else
+Font XLoadFont (dpy, name)
+ register Display *dpy;
+ char *name;
+#endif
+{
+ register long nbytes;
+ Font fid;
+ register xOpenFontReq *req;
+ LockDisplay(dpy);
+ GetReq(OpenFont, req);
+ nbytes = req->nbytes = name ? strlen(name) : 0;
+ req->fid = fid = XAllocID(dpy);
+ req->length += (nbytes+3)>>2;
+ Data (dpy, name, nbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (fid);
+ /* can't return (req->fid) since request may have already been sent */
+}
+
diff --git a/src/LockDis.c b/src/LockDis.c
new file mode 100644
index 00000000..91766791
--- /dev/null
+++ b/src/LockDis.c
@@ -0,0 +1,90 @@
+/* $Xorg: LockDis.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+
+/*
+
+Copyright 1993, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Author: Stephen Gildea, MIT X Consortium
+ *
+ * XLockDis.c - multi-thread application-level locking routines
+ */
+
+#include "Xlibint.h"
+#ifdef XTHREADS
+#include "locking.h"
+#endif
+
+#if NeedFunctionPrototypes
+void XLockDisplay(
+ register Display* dpy)
+#else
+void XLockDisplay(dpy)
+ register Display* dpy;
+#endif
+{
+#ifdef XTHREADS
+ LockDisplay(dpy);
+ if (dpy->lock)
+ (*dpy->lock->user_lock_display)(dpy);
+ /*
+ * We want the threads in the reply queue to all get out before
+ * XLockDisplay returns, in case they have any side effects the
+ * caller of XLockDisplay was trying to protect against.
+ * XLockDisplay puts itself at the head of the event waiters queue
+ * to wait for all the replies to come in.
+ */
+ if (dpy->lock && dpy->lock->reply_awaiters) {
+ struct _XCVList *cvl;
+
+ cvl = (*dpy->lock->create_cvl)(dpy);
+
+ /* stuff ourselves on the head of the queue */
+ cvl->next = dpy->lock->event_awaiters;
+ dpy->lock->event_awaiters = cvl;
+
+ while (dpy->lock->reply_awaiters)
+ ConditionWait(dpy, cvl->cv);
+ UnlockNextEventReader(dpy); /* pass the signal on */
+ }
+ UnlockDisplay(dpy);
+#endif
+}
+
+#if NeedFunctionPrototypes
+void XUnlockDisplay(
+ register Display* dpy)
+#else
+void XUnlockDisplay(dpy)
+ register Display* dpy;
+#endif
+{
+#ifdef XTHREADS
+ LockDisplay(dpy);
+ if (dpy->lock)
+ (*dpy->lock->user_unlock_display)(dpy);
+ UnlockDisplay(dpy);
+#endif
+}
diff --git a/src/LookupCol.c b/src/LookupCol.c
new file mode 100644
index 00000000..b7f56d3d
--- /dev/null
+++ b/src/LookupCol.c
@@ -0,0 +1,104 @@
+/* $Xorg: LookupCol.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1985, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include <stdio.h>
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+extern void _XcmsRGB_to_XColor();
+extern void _XUnresolveColor();
+
+#if NeedFunctionPrototypes
+Status XLookupColor (
+ register Display *dpy,
+ Colormap cmap,
+ _Xconst char *spec,
+ XColor *def,
+ XColor *scr)
+#else
+Status XLookupColor (dpy, cmap, spec, def, scr)
+ register Display *dpy;
+ Colormap cmap;
+ char *spec;
+ XColor *def, *scr;
+#endif
+{
+ register int n;
+ xLookupColorReply reply;
+ register xLookupColorReq *req;
+ XcmsCCC ccc;
+ XcmsColor cmsColor_exact;
+
+ /*
+ * Let's Attempt to use Xcms and i18n approach to Parse Color
+ */
+ /* copy string to allow overwrite by _XcmsResolveColorString() */
+ if ((ccc = XcmsCCCOfColormap(dpy, cmap)) != (XcmsCCC)NULL) {
+ if (_XcmsResolveColorString(ccc, &spec,
+ &cmsColor_exact, XcmsRGBFormat) >= XcmsSuccess) {
+ _XcmsRGB_to_XColor(&cmsColor_exact, def, 1);
+ memcpy((char *)scr, (char *)def, sizeof(XColor));
+ _XUnresolveColor(ccc, scr);
+ return(1);
+ }
+ /*
+ * Otherwise we failed; or spec was changed with yet another
+ * name. Thus pass name to the X Server.
+ */
+ }
+
+
+ /*
+ * Xcms and i18n methods failed, so lets pass it to the server
+ * for parsing.
+ */
+
+ n = strlen (spec);
+ LockDisplay(dpy);
+ GetReq (LookupColor, req);
+ req->cmap = cmap;
+ req->nbytes = n;
+ req->length += (n + 3) >> 2;
+ Data (dpy, spec, (long)n);
+ if (!_XReply (dpy, (xReply *) &reply, 0, xTrue)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (0);
+ }
+ def->red = reply.exactRed;
+ def->green = reply.exactGreen;
+ def->blue = reply.exactBlue;
+
+ scr->red = reply.screenRed;
+ scr->green = reply.screenGreen;
+ scr->blue = reply.screenBlue;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (1);
+}
diff --git a/src/LowerWin.c b/src/LowerWin.c
new file mode 100644
index 00000000..fb53df0a
--- /dev/null
+++ b/src/LowerWin.c
@@ -0,0 +1,46 @@
+/* $Xorg: LowerWin.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XLowerWindow(dpy, w)
+Display *dpy;
+Window w;
+{
+ register xConfigureWindowReq *req;
+ unsigned long val = Below; /* needed for macro */
+
+ LockDisplay(dpy);
+ GetReqExtra(ConfigureWindow, 4, req);
+ req->window = w;
+ req->mask = CWStackMode;
+ OneDataCard32 (dpy, NEXTPTR(req,xConfigureWindowReq), val);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/Macros.c b/src/Macros.c
new file mode 100644
index 00000000..61188588
--- /dev/null
+++ b/src/Macros.c
@@ -0,0 +1,250 @@
+/* $Xorg: Macros.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+/*
+ * This file makes full definitions of routines for each macro.
+ * We do not expect C programs to use these, but other languages may
+ * need them.
+ */
+
+int XConnectionNumber(dpy) Display *dpy; { return (ConnectionNumber(dpy)); }
+
+Window XRootWindow (dpy, scr)
+ Display *dpy; int scr;
+ { return (RootWindow(dpy,scr)); }
+
+int XDefaultScreen(dpy) Display *dpy; { return (DefaultScreen(dpy)); }
+
+Window XDefaultRootWindow (dpy)
+ Display *dpy;
+ { return (RootWindow(dpy,DefaultScreen(dpy))); }
+
+Visual *XDefaultVisual(dpy, scr)
+ Display *dpy; int scr;
+ { return (DefaultVisual(dpy, scr)); }
+
+GC XDefaultGC(dpy, scr)
+ Display *dpy; int scr;
+ { return (DefaultGC(dpy,scr)); }
+
+unsigned long XBlackPixel(dpy, scr)
+ Display *dpy; int scr;
+ { return (BlackPixel(dpy, scr)); }
+
+unsigned long XWhitePixel(dpy, scr)
+ Display *dpy; int scr;
+ { return (WhitePixel(dpy,scr)); }
+
+unsigned long XAllPlanes() { return AllPlanes; }
+
+int XQLength(dpy) Display *dpy; { return (QLength(dpy)); }
+
+int XDisplayWidth(dpy, scr)
+ Display *dpy; int scr;
+ { return (DisplayWidth(dpy,scr)); }
+
+int XDisplayHeight(dpy, scr)
+ Display *dpy; int scr;
+ { return (DisplayHeight(dpy, scr)); }
+
+int XDisplayWidthMM(dpy, scr)
+ Display *dpy; int scr;
+ { return (DisplayWidthMM(dpy, scr)); }
+
+int XDisplayHeightMM(dpy, scr)
+ Display *dpy; int scr;
+ { return (DisplayHeightMM(dpy, scr)); }
+
+int XDisplayPlanes(dpy, scr)
+ Display *dpy; int scr;
+ { return (DisplayPlanes(dpy, scr)); }
+
+int XDisplayCells(dpy, scr)
+ Display *dpy; int scr;
+ { return (DisplayCells (dpy, scr)); }
+
+int XScreenCount(dpy) Display *dpy; { return (ScreenCount(dpy)); }
+
+char *XServerVendor(dpy) Display *dpy; { return (ServerVendor(dpy)); }
+
+int XProtocolVersion(dpy) Display *dpy; { return (ProtocolVersion(dpy)); }
+
+int XProtocolRevision(dpy) Display *dpy; { return (ProtocolRevision(dpy));}
+
+int XVendorRelease(dpy) Display *dpy; { return (VendorRelease(dpy)); }
+
+char *XDisplayString(dpy) Display *dpy; { return (DisplayString(dpy)); }
+
+int XDefaultDepth(dpy, scr)
+ Display *dpy; int scr;
+ { return(DefaultDepth(dpy, scr)); }
+
+Colormap XDefaultColormap(dpy, scr)
+ Display *dpy; int scr;
+ { return (DefaultColormap(dpy, scr)); }
+
+int XBitmapUnit(dpy) Display *dpy; { return (BitmapUnit(dpy)); }
+
+int XBitmapBitOrder(dpy) Display *dpy; { return (BitmapBitOrder(dpy)); }
+
+int XBitmapPad(dpy) Display *dpy; { return (BitmapPad(dpy)); }
+
+int XImageByteOrder(dpy) Display *dpy; { return (ImageByteOrder(dpy)); }
+
+unsigned long XNextRequest(dpy)
+ Display *dpy;
+ {
+#ifdef WORD64
+ WORD64ALIGN
+ return dpy->request + 1;
+#else
+ return (NextRequest(dpy));
+#endif
+ }
+
+unsigned long XLastKnownRequestProcessed(dpy)
+ Display *dpy;
+ { return (LastKnownRequestProcessed(dpy)); }
+
+/* screen oriented macros (toolkit) */
+Screen *XScreenOfDisplay(dpy, scr) Display *dpy; int scr;
+ { return (ScreenOfDisplay(dpy, scr)); }
+
+Screen *XDefaultScreenOfDisplay(dpy) Display *dpy;
+ { return (DefaultScreenOfDisplay(dpy)); }
+
+Display *XDisplayOfScreen(s) Screen *s; { return (DisplayOfScreen(s)); }
+
+Window XRootWindowOfScreen(s) Screen *s; { return (RootWindowOfScreen(s)); }
+
+unsigned long XBlackPixelOfScreen(s) Screen *s;
+ { return (BlackPixelOfScreen(s)); }
+
+unsigned long XWhitePixelOfScreen(s) Screen *s;
+ { return (WhitePixelOfScreen(s)); }
+
+Colormap XDefaultColormapOfScreen(s) Screen *s;
+ { return (DefaultColormapOfScreen(s)); }
+
+int XDefaultDepthOfScreen(s) Screen *s; { return (DefaultDepthOfScreen(s)); }
+
+GC XDefaultGCOfScreen(s) Screen *s; { return (DefaultGCOfScreen(s)); }
+
+Visual *XDefaultVisualOfScreen(s) Screen *s;
+ { return (DefaultVisualOfScreen(s)); }
+
+int XWidthOfScreen(s) Screen *s; { return (WidthOfScreen(s)); }
+
+int XHeightOfScreen(s) Screen *s; { return (HeightOfScreen(s)); }
+
+int XWidthMMOfScreen(s) Screen *s; { return (WidthMMOfScreen(s)); }
+
+int XHeightMMOfScreen(s) Screen *s; { return (HeightMMOfScreen(s)); }
+
+int XPlanesOfScreen(s) Screen *s; { return (PlanesOfScreen(s)); }
+
+int XCellsOfScreen(s) Screen *s; { return (CellsOfScreen(s)); }
+
+int XMinCmapsOfScreen(s) Screen *s; { return (MinCmapsOfScreen(s)); }
+
+int XMaxCmapsOfScreen(s) Screen *s; { return (MaxCmapsOfScreen(s)); }
+
+Bool XDoesSaveUnders(s) Screen *s; { return (DoesSaveUnders(s)); }
+
+int XDoesBackingStore(s) Screen *s; { return (DoesBackingStore(s)); }
+
+long XEventMaskOfScreen(s) Screen *s; { return (EventMaskOfScreen(s)); }
+
+int XScreenNumberOfScreen (scr)
+ register Screen *scr;
+{
+ register Display *dpy = scr->display;
+ register Screen *dpyscr = dpy->screens;
+ register int i;
+
+ for (i = 0; i < dpy->nscreens; i++, dpyscr++) {
+ if (scr == dpyscr) return i;
+ }
+ return -1;
+}
+
+/*
+ * These macros are used to give some sugar to the image routines so that
+ * naive people are more comfortable with them.
+ */
+#undef XDestroyImage
+XDestroyImage(ximage)
+ XImage *ximage;
+{
+ return((*((ximage)->f.destroy_image))((ximage)));
+}
+#undef XGetPixel
+unsigned long XGetPixel(ximage, x, y)
+ XImage *ximage;
+ int x, y;
+{
+ return ((*((ximage)->f.get_pixel))((ximage), (x), (y)));
+}
+#undef XPutPixel
+int XPutPixel(ximage, x, y, pixel)
+ XImage *ximage;
+ int x, y;
+ unsigned long pixel;
+{
+ return((*((ximage)->f.put_pixel))((ximage), (x), (y), (pixel)));
+}
+#undef XSubImage
+XImage *XSubImage(ximage, x, y, width, height)
+ XImage *ximage;
+ int x, y;
+ unsigned int width, height;
+{
+ return((*((ximage)->f.sub_image))((ximage), (x),
+ (y), (width), (height)));
+}
+#undef XAddPixel
+int XAddPixel(ximage, value)
+ XImage *ximage;
+ long value;
+{
+ return((*((ximage)->f.add_pixel))((ximage), (value)));
+}
+
+
+XNoOp (dpy)
+ register Display *dpy;
+{
+ register xReq *req;
+
+ LockDisplay(dpy);
+ GetEmptyReq(NoOperation, req);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/MapRaised.c b/src/MapRaised.c
new file mode 100644
index 00000000..e00cb75a
--- /dev/null
+++ b/src/MapRaised.c
@@ -0,0 +1,48 @@
+/* $Xorg: MapRaised.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XMapRaised (dpy, w)
+ Window w;
+ register Display *dpy;
+{
+ register xConfigureWindowReq *req;
+ register xResourceReq *req2;
+ unsigned long val = Above; /* needed for macro */
+
+ LockDisplay(dpy);
+ GetReqExtra(ConfigureWindow, 4, req);
+ req->window = w;
+ req->mask = CWStackMode;
+ OneDataCard32 (dpy, NEXTPTR(req,xConfigureWindowReq), val);
+ GetResReq (MapWindow, w, req2);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/MapSubs.c b/src/MapSubs.c
new file mode 100644
index 00000000..39589e93
--- /dev/null
+++ b/src/MapSubs.c
@@ -0,0 +1,40 @@
+/* $Xorg: MapSubs.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XMapSubwindows(dpy, win)
+ register Display *dpy;
+ Window win;
+{
+ register xResourceReq *req;
+ LockDisplay(dpy);
+ GetResReq(MapSubwindows, win, req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/MapWindow.c b/src/MapWindow.c
new file mode 100644
index 00000000..e0c06efe
--- /dev/null
+++ b/src/MapWindow.c
@@ -0,0 +1,41 @@
+/* $Xorg: MapWindow.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XMapWindow (dpy, w)
+ Window w;
+ register Display *dpy;
+{
+ register xResourceReq *req;
+ LockDisplay (dpy);
+ GetResReq(MapWindow, w, req);
+ UnlockDisplay (dpy);
+ SyncHandle()